I am unable to find xpath of "BBB" in following span class example.
<span class="xyz"> "AAA" "BBB" "CCC" ==$0 </span>
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communityI am unable to find xpath of "BBB" in following span class example.
<span class="xyz"> "AAA" "BBB" "CCC" ==$0 </span>
<span class="xyz"> "AAA" "BBB" "CCC" ==$0 </span>
In your sample HTML, "BBB" isn't an element. It is text (substring) within the element <span></span>
.
Xpaths are ment to identify elements. So if your HTML is like this,
<html>
<body>
<span class="xyz"> "AAA" "BBB" "CCC" ==$0 </span>
</body>
</html>
Then you can use these examples to find the element with Xpath,
Full Xpath: /html/body/span
Xpath with attribute: //span[@class='xyz']
Xpath contains substring: //span[contains(text(),'BBB')]
while providing automation testing services we need to have good grip on xpath creation because in few o the applications id's and classes even if defined doesn't work. So xpath's can be more helpful in such kind of situations. we can directly create xpath for the above using text of that particular element but here we can involve class of that particular element and can create the xpath in the following manner:
//span[@class='xyz'][contains(text(),'BBB')]