How to execute javascript on page and save result

You can execute javascript globally or on custom object.

To execute javascript globally, use “Javascript” action:

Code will be executed in browser context.

All global variables like document, window, etc is available.

$ is available if page uses jquery.

After script will be executed, result will be saved to user defined variable. SAVED_SCRIPT_RESULT by default.

SAVED_SCRIPT_RESULT is always string, any other type will be converted to string.

If javascript code will throw exception, SAVED_SCRIPT_RESULT variable will hold empty string.



Another possibility to execute javascript is to use “Execute Javascript On Element” in element context menu:

That action is the same as global “Javascript” action, except it exposes “self” variable.

“self” variable points to element, which triggered context menu.



Here is some usefull examples om how to use javascript functionality in BAS:



Get input field value:

self.value



Pure javascript click:

self.click()



Get element top coordinate:

self.getBoundingClientRect().top

Following tutorial shows, how to execute javascript: