Reputation: 1
I'm working on a Selenium Project.
I have a HTML File (copied below) for which I have to write a XPath expression in order to find out the value of 6th "b" element under "a" for which:
<a>
<b>111</b>
<b>222</b>
<b>333</b>
<b>444</b>
<b>ttt</b>
<b>uuu</b>
</a>
<a>
<b>999</b>
<b>888</b>
<b>777</b>
<b>World is Great</b>
<b>aaa</b>
<b>bbb</b>
</a>
I tried the following, but didn't work. Any help will be appreciated.
//a[b='888'][b='World is Great']/b[6]
//a[contains(@b[2], '888') and contains(@b[4], 'World is Great')]/b[6]
Upvotes: 0
Views: 50
Reputation: 9627
Q.: (modified) to find out the value of 6th "b" element under "a" for which - -- 2nd "b" has a value of "888" and -- 4th "b" has a value of "World is Great"
Try this:
"//a[b[2]='888' and b[4] = 'World is Great' ]/b[6]"
Attention:
But your fist try //a[b='888'][b='World is Great']/b[6]
should also work. If it does not return "bbb" for your example there is something else wrong.
Upvotes: 2