For Python, getting WebDriverException: Message: u'[JavaScript Error: "e is null"
For Python, getting WebDriverException: Message: u'[JavaScript Error: "e is null"
我遇到过一个似乎只在特定条件下在 Firefox 上失败的情况。在我的代码中...
driver.get(url('/Points/Inputs/'))
assertRowTrue(driver, 2, 11, "True")
我收到错误...
E WebDriverException: Message: u'[JavaScript Error: "e is null" {file:
"file:///tmp/anonymous7279155570809486473webdriver-profile/extensions/fxdriver@
googlecode.com/components/command-processor.js" line: 7854}]\'[JavaScript Error:
"e is null" {file: "file:///tmp/anonymous7279155570809486473webdriver-profile/e
xtensions/fxdriver@googlecode.com/components/command-processor.js" line: 7854}]\
' when calling method: [nsICommandProcessor::execute]\nBuild info: version: \'2.
43.0\', revision: \'597b76b\', time: \'2014-09-09 20:52:14\'\nSystem info: host:
\'8efca6f08729\', ip: \'172.17.0.3\', os.name: \'Linux\', os.arch: \'amd64\', o
s.version: \'3.13.0-24-generic\', java.version: \'1.7.0_65\'\nDriver info: drive
r.version: unknown' ; Screenshot: available via screen
环顾四周,这个问题在上一个问题中被提及和解释 here。我的特定情况的问题是它不是警报的结果,所以当我尝试关闭警报时...
driver.switch_to_alert().dismiss()
...我收到 NoAlertPresentException
。
在 Selenium 解决这个问题之前,如果警报不是罪魁祸首,是否有办法解决这个错误?
更新(2015 年 6 月 6 日)
尝试下面列出的答案工作了一段时间,但又回到了我看到的原始错误。这是我失败的测试示例。
嘿@alecxc。这是一个失败的例子。我访问了一个特定的网页,以验证 [in a table] 中的一行是否包含我期望的信息。为此,我使用了自己的定义 assertRowTrue()
assertRowTrue(driver, 2, 11, "Online")
这个定义,我已经创建了代码。
def assertRowTrue(driver, row, column, value):
try:
WebDriverWait(driver, 30).until(
expected_conditions.text_to_be_present_in_element((By.XPATH, "//tr["+str(row)+"]/td["+str(column)+"]/div"), value)
)
except TimeoutException:
raise Exception("ERROR : VALUE NOT EQUAL TO EXPECTED VALUE \""+value+"\". ACTUAL VALUE: ", driver.find_element_by_xpath("//tr["+str(row)+"]/td["+str(column)+"]/div").text)
..其中行和列指向table和值[中的位置=44=] 表示那里的期望值。在 Firefox 上,它在代码的 expected_condition() 部分失败。 Chrome,但是,运行此代码没有任何错误。
您在 selenium
2.43 和 firefox
36 之间遇到兼容性问题。
现在最简单的选择是 将 selenium 升级到 2.45:
pip install --upgrade selenium
我遇到过一个似乎只在特定条件下在 Firefox 上失败的情况。在我的代码中...
driver.get(url('/Points/Inputs/'))
assertRowTrue(driver, 2, 11, "True")
我收到错误...
E WebDriverException: Message: u'[JavaScript Error: "e is null" {file:
"file:///tmp/anonymous7279155570809486473webdriver-profile/extensions/fxdriver@
googlecode.com/components/command-processor.js" line: 7854}]\'[JavaScript Error:
"e is null" {file: "file:///tmp/anonymous7279155570809486473webdriver-profile/e
xtensions/fxdriver@googlecode.com/components/command-processor.js" line: 7854}]\
' when calling method: [nsICommandProcessor::execute]\nBuild info: version: \'2.
43.0\', revision: \'597b76b\', time: \'2014-09-09 20:52:14\'\nSystem info: host:
\'8efca6f08729\', ip: \'172.17.0.3\', os.name: \'Linux\', os.arch: \'amd64\', o
s.version: \'3.13.0-24-generic\', java.version: \'1.7.0_65\'\nDriver info: drive
r.version: unknown' ; Screenshot: available via screen
环顾四周,这个问题在上一个问题中被提及和解释 here。我的特定情况的问题是它不是警报的结果,所以当我尝试关闭警报时...
driver.switch_to_alert().dismiss()
...我收到 NoAlertPresentException
。
在 Selenium 解决这个问题之前,如果警报不是罪魁祸首,是否有办法解决这个错误?
更新(2015 年 6 月 6 日)
尝试下面列出的答案工作了一段时间,但又回到了我看到的原始错误。这是我失败的测试示例。
嘿@alecxc。这是一个失败的例子。我访问了一个特定的网页,以验证 [in a table] 中的一行是否包含我期望的信息。为此,我使用了自己的定义 assertRowTrue()
assertRowTrue(driver, 2, 11, "Online")
这个定义,我已经创建了代码。
def assertRowTrue(driver, row, column, value):
try:
WebDriverWait(driver, 30).until(
expected_conditions.text_to_be_present_in_element((By.XPATH, "//tr["+str(row)+"]/td["+str(column)+"]/div"), value)
)
except TimeoutException:
raise Exception("ERROR : VALUE NOT EQUAL TO EXPECTED VALUE \""+value+"\". ACTUAL VALUE: ", driver.find_element_by_xpath("//tr["+str(row)+"]/td["+str(column)+"]/div").text)
..其中行和列指向table和值[中的位置=44=] 表示那里的期望值。在 Firefox 上,它在代码的 expected_condition() 部分失败。 Chrome,但是,运行此代码没有任何错误。
您在 selenium
2.43 和 firefox
36 之间遇到兼容性问题。
现在最简单的选择是 将 selenium 升级到 2.45:
pip install --upgrade selenium