I have the following markup:
<div>
<div>Question1</div>
<div>
<button type="button">No</button>
<button type="button">Yes</button>
</div>
</div>
<div>
<div>Question2</div>
<div>
<button type="button">No</button>
<button type="button">Yes</button>
</div>
</div>
The following XPath expression locates two yes buttons:
//div/div/button[text()='Yes']
However I only want the Yes button of the first div as in:
//div/div[text()='Question1']
How can I locate that?
Use:
This selects any
buttonwhose string value is"Yes"and whosetypeattribute has string value"button"and (thebuttonelement) is child of adivthat is a child of adivthat has adivchild with string value"Question1".