I am encountering a very unusual thing, the one I haven't seen before. There is one element I needed to find for testing purposes, it is visible on the page and I can find its unique relative XPath with rclick-->inspect option, but in run time it is not recognized. Here is more info:
I know for sure that the element is not in any of the frames because I checked and all frames have different XPath.
I tried to get all elements of the page and print their text (the element I need does have text) with //* option and the text I needed wasn't printed
I tried full XPath and very strangely beside the element I need, there is another element with the same full XPath. For sure relative XPath can be duplicate, but I thought it is not possible with full XPath. How can it happen?
Also, when I used that full XPath to put all elements in a list, the size of the list was 1. In other words, it found the other element, not the one I needed. How can all that happen?
The XPaths are:
- relative -
//*[@id='NoChainFound']
- absolute -
/html/body/div[5]/div[2]
The HTML I am looking at is:
<div id="NoChainFound" ng-show="!inGantt && isChainEmpty() && serviceId">This service appointment has no scheduling dependencies.
<a class="learn-more" href="help.salesforce.com/articleView?id=pfs_complex_work.htm" target="_blank">Learn More</a>
</div>
My code is:
WebElement message = driver.findElement (By.xpath("//*[@id='NoChainFound']"));
And the error is:
no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='NoChainFound']"}(Session info: chrome=79.0.3945.88)(Driver info: chromedriver=2.40.565498