3

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?

unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677
user652124
  • 51
  • 2
  • 3
  • 4
    Was able to resolve this. I was missing a return in the execute_script. wd.execute_script("return window.$('body form div ul li').html()") – user652124 Mar 10 '11 at 00:48
  • it's ok to answer your own question and accept it. it'll be easier to find the right answer if you do this. – Joe Shaw Oct 01 '11 at 16:34

1 Answers1

4

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.

Randall Bohn
  • 2,597
  • 2
  • 16
  • 20