Argus9 Argus9 - 5 months ago 40
Ruby Question

Ruby Selenium WebDriver - get return value of execute_script

Simple question here - when I use

execute_script
in a Ruby Selenium test, is there a way I can get the result of the JavaScript I ran?

This is the code I'm executing:
driver.execute_script '$.active'


Edit: The solution is so simple. I forgot to include
return
in the script.

Answer

You just need to add the return:

driver.execute_script 'return $.active'