在 Python 中实现 WebdriverBackedSelenium [英] Implementing WebdriverBackedSelenium in Python
问题描述
我升级到 Selenium 2.20 以在 Python 中使用 Webdriver 支持的 Selenium.我这样做是为了我可以使用 Webdriver 运行我的测试,而不必重写我的所有测试用例.我试图按照 http://seleniumhq.wordpress.com/2012/02/08/announcing-selenium-2-19-the-prancing-unicorn-release/ 但我发现其中两个函数:RemoteWebDriver() 和我的代码库中不存在 DefaultSelenium().相反,我使用了我能找到的最接近的函数:分别是 webdriver.Remote() 和 selenium().这两个似乎具有相同的功能,但是当我尝试运行测试用例时,我收到错误KeyError: webdriver.remote.sessionid".
I upgraded to Selenium 2.20 to use Webdriver backed Selenium in Python. I did this so I could run my tests using Webdriver without having to rewrite all of my test cases. I attempted to follow the example at http://seleniumhq.wordpress.com/2012/02/08/announcing-selenium-2-19-the-prancing-unicorn-release/ but I found that two of the functions: RemoteWebDriver() and DefaultSelenium() do not exist in my code base. Instead I used the closest functions I could find: webdriver.Remote() and selenium() respectively. These two SEEM to have the same functionality, but when I attempt to run the test case I receive the error "KeyError: webdriver.remote.sessionid".
这里是示例代码供参考:
For reference here is the example code:
driver = RemoteWebDriver(desired_capabilities = DesiredCapabilities.FIREFOX)
selenium = DefaultSelenium('localhost', 4444', '*webdriver', 'http://www.google.com')
selenium.start(driver = driver)
这是我正在使用的代码:
And here is the code that I'm using:
self.webdriver = webdriver.Remote(desired_capabilities=DesiredCapabilities.FIREFOX)
self.selenium = selenium('localhost', 4444, '*webdriver', SITE)
self.selenium.start(driver = self.webdriver)
注意:我在模块之间传递 self ,忽略它.此外,SITE 是一个全局变量,用于保存我的测试站点的 url.也忽略它.
Note: I pass self in between modules, ignore it. Also, SITE is a global variable that holds the url to my test site. Ignore it as well.
如果有什么需要澄清的,请告诉我.
Please let me know if anything needs to be clarified.
推荐答案
我遇到了同样的问题.我提交了一个补丁来修复它.
I had the same problem. I submitted a patch to fix it.
http://code.google.com/p/selenium/问题/详细信息?id=4283
这篇关于在 Python 中实现 WebdriverBackedSelenium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!