所以我有一个网页,只有当div entire class
中存在按钮 NameField 时,我才想找到按钮 SignUp 。
<div class="entire class">
<div class = "upper class>
<button class="NameField"></button>
</div>
<div class="lower class">
<button class="SignUp"></button>
</div>
</div>
我将如何实现这一目标?我尝试过以下方法:
$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']]")
他们似乎都没有工作。
答案 0 :(得分:1)
请尝试以下//div[button[@class="NameField"]]/following-sibling::div/button[@class="SignUp"]
//div[@class="entire class" and div[button[@class="NameField"]]]/div/button[@class="SignUp"]
:
//button[@class="NameField"]/following::button
或简化的:
{{1}}