When I check an XPath in Firebug, it works as expected.
The XPath I'm trying is below:
.//div[Text()='Data Fields']/following::div[contains(@style,'db3a1a10.pn`g')][2]
However, in Selenium WebDriver
ArrayList<WebElement> al = toolActionObject.getAllElementsByXpath(".//div[Text()='Data Fields']/following::div[contains(@style,'db3a1a10.png')][2]");
System.out.println(al.size());
the output lines are like
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
What is the reason for such conflicting behavior?
You have two issues in your XPath. text()
needs to be written lowercase and 'db3a1a10.png'
(probably just an error in your example code) must not contain a tickmark.