Reputation: 37
So I have a web page where I would like to find button SignUp only if button NameField is present in the div entire class
.
<div class="entire class">
<div class = "upper class>
<button class="NameField"></button>
</div>
<div class="lower class">
<button class="SignUp"></button>
</div>
</div>
How would I achieve that? I have tried the following:
$x("//div[@class='entire class']//button[@class='NameField'] and not(descendant::button[@class='SignUp']")
$x("//*[@class='upper class'] | [@class='SignUp']")
$x("//*[@class='SignUp'] | //body)[last()]")
$x("//div[//button[@class='SignUp'] and [//button[@class='NameField']]")
None of them seems to be working.
Upvotes: 0
Views: 48
Reputation: 52685
Try below XPath
:
//div[button[@class="NameField"]]/following-sibling::div/button[@class="SignUp"]
//div[@class="entire class" and div[button[@class="NameField"]]]/div/button[@class="SignUp"]
or simplified one:
//button[@class="NameField"]/following::button
Upvotes: 1