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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.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
Xpath 在Firebug中发现元素,但在Selenium中未发现_Xpath_Selenium Webdriver_Webdriver_Firebug - Fatal编程技术网

Xpath 在Firebug中发现元素,但在Selenium中未发现

Xpath 在Firebug中发现元素,但在Selenium中未发现,xpath,selenium-webdriver,webdriver,firebug,Xpath,Selenium Webdriver,Webdriver,Firebug,当我在Firebug中检查XPath时,它按预期工作 我正在尝试的XPath如下所示: .//div[Text()='Data Fields']/following::div[contains(@style,'db3a1a10.pn`g')][2] 但是,在SeleniumWebDriver中 ArrayList<WebElement> al = toolActionObject.getAllElementsByXpath(".//div[Text()='Data Fields

当我在Firebug中检查XPath时,它按预期工作

我正在尝试的XPath如下所示:

.//div[Text()='Data Fields']/following::div[contains(@style,'db3a1a10.pn`g')][2]

但是,在SeleniumWebDriver中

 ArrayList<WebElement> al = toolActionObject.getAllElementsByXpath(".//div[Text()='Data Fields']/following::div[contains(@style,'db3a1a10.png')][2]");
 System.out.println(al.size());

这种冲突行为的原因是什么?

XPath中有两个问题
text()
需要用小写字母编写,并且
'db3a1a10.png'
(可能只是示例代码中的一个错误)不能包含勾号。

什么是
toolActionObject
?我正在开发一个框架。在我们的框架中,我们有一个名为SeleniumActions的类,在该类中,我们定义了通过id、xpath等访问Web元素的方法。toolActionObject是SeleniumActions的实例。请将相关html(从xpath开始)添加为文本。很可能
如下:
不起作用。检查跨浏览器兼容性。是的,我正在尝试Text(),它应该是Text()。
DEBUG (SeleniumActions.java:91) - Locating elements by By.xpath: *//div[Text()='Data Fields']/following::div[contains(@style,'db3a1a10.png')][2]
DEBUG (SeleniumActions.java:91) - Locating elements by By.xpath: *//div[Text()='Data Fields']/following::div[contains(@style,'db3a1a10.png')][2]
DEBUG (SeleniumActions.java:91) - Locating elements by By.xpath: *//div[Text()='Data Fields']/following::div[contains(@style,'db3a1a10.png')][2]
DEBUG (SeleniumActions.java:91) - Locating elements by By.xpath: *//div[Text()='Data Fields']/following::div[contains(@style,'db3a1a10.png')][2]
DEBUG (SeleniumActions.java:91) - Locating elements by By.xpath: *//div[Text()='Data Fields']/following::div[contains(@style,'db3a1a10.png')][2]
DEBUG (SeleniumActions.java:111) - Exception : Elements not found.
 Cause : Elements not found by By.xpath: *//div[Text()='Data Fields']/following::div[contains(@style,'db3a1a10.png')][2]. Returning empty Array List of WebElement.
0
 INFO (GSUILogInLogOut.java:95) - Clossing browser.
PASSED: testHere