Implementing WebdriverBackedSelenium in Python

2020-08-01 05:41发布

问题:

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)

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.

回答1:

I had the same problem. I submitted a patch to fix it.

http://code.google.com/p/selenium/issues/detail?id=4283