Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the get_eval equivalent for selenium webdriver in python

The following works fine in selenium-1:

sel = self.selenium 
sel.get_eval("window.$('body form div ul li').html()")

When I try to the same in selenium-2 webdriver in python, I get a error.

wd = webdriver.Firefox()
wd.execute_script("window.$('body form div ul li').html()")

selenium.webdriver.common.exceptions.WebDriverException: window.$ is not a function

How can get that jquery to work in webdriver in python?

like image 928
user652124 Avatar asked Aug 26 '26 01:08

user652124


1 Answers

In selenium1 get_eval() evaluates a script and returns the result.

When you use execute_script() you have to explicitly return the value in which you are interested.

like image 161
Randall Bohn Avatar answered Aug 28 '26 14:08

Randall Bohn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!