由于Selenium库中存在Javascript错误,我的测试有时会失败:
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]
测试有时会成功执行,但似乎是随机的失败。
我正在使用Firefox WebDriver。
导致异常的代码是:
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
有没有人对可能导致此问题的原因或如何调试此错误有任何想法?
由于