jeudi 21 mai 2015

"h is null" sometimes when performing Selenium tests

My tests sometimes fail because of a Javascript Error in the Selenium library:

Exception traceback: Traceback (most recent call last):
    File "run.py", line 292, in <module>
        r.play()
    File "run.py", line 256, in play
        self.run_downloads()
    File "run.py", line 146, in run_downloads
        self.run_download(download)
    File "run.py", line 167, in run_download
        executor.start()
    File "run.py", line 61, in start
        expected_conditions.presence_of_element_located((By.CLASS_NAME, "newsfeed-widget"))
    File "/srv/intex/venv/local/lib/python2.7/site-packages/selenium/webdriver/support/wait.py", line 66, in until
        value = method(self._driver)
    File "/srv/intex/venv/local/lib/python2.7/site-packages/selenium/webdriver/support/expected_conditions.py", line 58, in __call__
        return _find_element(driver, self.locator)
    File "/srv/intex/venv/local/lib/python2.7/site-packages/selenium/webdriver/support/expected_conditions.py", line 279, in _find_element
        raise e
WebDriverException: Message: [JavaScript Error: "h is null" {file: "file:///tmp/tmpv9LZnL/extensions/fxdriver@googlecode.com/components/command-processor.js" line: 8478}]'[JavaScript Error: "h is null" {file: "file:///tmp/tmpv9LZnL/extensions/fxdriver@googlecode.com/components/command-processor.js" line: 8478}]' when calling method: [nsICommandProcessor::execute]

The tests sometimes perform successsfully, but fail in what appears to be a random fashion.

I am using the Firefox WebDriver.

The code that causes the exception is:

self.driver.find_element_by_name("button1").click()
try:
    WebDriverWait(self.driver, 60).until(
        expected_conditions.presence_of_element_located((By.CLASS_NAME, "newsfeed-widget")) #  This line throws the exception
    )
except TimeoutException:
    pass

Does anyone have any ideas on what could be causing this or how I can debug this error?

Thanks

Aucun commentaire:

Enregistrer un commentaire