Issue
I got this web page to test whether this element contains a certain keyword in it.
<div>
" "
"Network interface updated successfully"
</div>
This is the HTML code and the xpath I am trying to get is
//div[contains(text(),'interface')]
But this xpath doesn't find this element at all. So I tried different way to figure out how it works.
//div/text()[2]
This xpath matches up the element, but it is not the best practice for me.
I attached the screen shot what I am suffering.....
Solution
I Found Something similar to your example here
now if you want the entire text enclosed within that element and you dont want to index through the scripts you can do it via java script executor
run the below statement with java script executor and it will return the entire text, once you fetch the text you can assert if it contains the expected text.
'return $x("//div[@class='jconfirm-content']//div//div")[0].textContent'
Answered By - Rohit
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.