以下代码在selenium-1中运行良好:
sel = self.selenium
sel.get_eval("window.$('body form div ul li').html()")当我尝试在python中的selenium-2 webdriver中执行相同的操作时,我得到了一个错误。
wd = webdriver.Firefox()
wd.execute_script("window.$('body form div ul li').html()")
selenium.webdriver.common.exceptions.WebDriverException: window.$ is not a function如何让jquery在python中的webdriver中工作?
发布于 2011-05-02 23:05:34
在selenium1中,get_eval()计算脚本并返回结果。
当您使用execute_script()时,您必须显式返回您感兴趣的值。
https://stackoverflow.com/questions/5251079
复制相似问题