Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 给定的选择器注释按钮无效或未生成WebElement_Selenium_Xpath_Selenium Webdriver - Fatal编程技术网

Selenium 给定的选择器注释按钮无效或未生成WebElement

Selenium 给定的选择器注释按钮无效或未生成WebElement,selenium,xpath,selenium-webdriver,Selenium,Xpath,Selenium Webdriver,我的Selenium服务器在尝试使用Xpath/*[@id=“someid”]/div/div/div/a访问dom元素时生成以下错误 WARN - Exception: The given selector Comments button is either invalid or does not result in a WebElement. The following error occurred: InvalidSelectorError: Unable to locate an ele

我的Selenium服务器在尝试使用Xpath
/*[@id=“someid”]/div/div/div/a
访问dom元素时生成以下错误

WARN - Exception: The given selector Comments button is either invalid or does not result in a WebElement. The following error occurred:
InvalidSelectorError: Unable to locate an element with the xpath expression Comments button because of the following error:
SyntaxError: The expression is not a legal expression.
For documentation on this error, please visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html
当在控制台中使用Firefox时,此XPath可以正常工作,但在使用SeleniumHQ+FacebookWebDriver运行自动测试时失败,当然上述情况除外


Xpath对我来说似乎没什么问题。

可能有很多东西

可能webdriver启动并完成查找,但元素尚未加载,或者元素不可见,或者元素顶部有另一个不允许您交互的元素

可能您正在使用不同的浏览器来执行测试(而不是firefox)。在IE中,HTML代码可能不同,您可能有额外或更少的HTML元素

也许你可以手动访问该网页,然后自动重定向到另一个网页(例如,你在google.fr中记录测试,然后自动转到google.com)


有很多可能性。

听起来可能是您的Selenium代码误用了引号或其他东西,因此文本字符串
注释按钮
被理解为XPath表达式

通常,该错误消息在“给定选择器”之后显示实际的XPath表达式,如中所示

给定选择器 //输入[@type=checkbox]/以下同级:://td[contains(text(),template] 无效或未生成WebElement


元素确实是通过javascript显示的。我起初认为这可能是屏幕大小问题,但全屏显示也没有任何效果。听起来可能是Selenium代码误用了引号或其他东西,因此文本字符串
Comments按钮
被理解为XPath表达式。通常错误消息显示在“给定选择器”(例如)之后是实际的XPath表达式。您可以发布将XPath表达式发送到Selenium服务器的代码吗?