我想选择咨询服务和监管机构之间的元素按钮[...]。我尝试了许多xpath与前面和后面但它总是选择元素监督组织
我试过的最新Xpath:
(//div[text()='Consulting Services']/following::div[text()='Supervisory Organization'])[1][//preceding::ul//img[@title='Related Actions and Preview']]
Html:
<div class="WPJF">
<div class="WDVV WAUV WJ3 WEWV WCWV WDKF WAKF" data-automation-id="compositeHeader" id="56$284553">
<div class="WIVV">
<ul tabindex="-2" class="WIEP WHVV" role="presentation" data-automation-id="selectedItemList">
<li class="WMEP" role="presentation">
<div class="WCEP WLEP" tabindex="-2" id="fac7048965494633a57cb15651618375" data-automation-id="menuItem" aria-label="Consulting Services, press delete to clear value." role="presentation" aria-posinset="1" aria-setsize="1">
<div class="WDEP">
<div class="WMJN WKIN WCJN" data-automation-id="selectedItem_2500$199">
<ul class="WAJN"></ul>
<div class="gwt-Label WNJN WKIN" data-automation-id="promptOption" id="promptOption-gwt-uid-443" data-automation-label="Consulting Services" title="Consulting Services" aria-label="Consulting Services" role="link" tabindex="0">Consulting Services</div>
<ul class="WAJN WFJN" role="presentation">
<li class="WLJN"><img class="gwt-Image WLQO WFVP WPWP WBJN" src="https://impl.workday.com/wday/uiclient/static/gwt-desktop/update/WorkdayApp/8CB9E57BEDDE62E4F67DEB6E19F5308C.cache.png" draggable="false" data-automation-id="RELATED_TASK_charm" alt="" aria-label="Related Actions and Preview" title="Related Actions and Preview" aria-labelledby="promptOption-gwt-uid-443"></li>
</ul>
</div>
</div>
</div>
</li>
</ul>
</div>
<div data-automation-id="wd-MoreLink" data-automation-morelinkexpanded="false" role="button" id="968c25d5792a4c2eaf6ca6028f1e8fdf" class="WK3P WJ3P" tabindex="0" aria-labelledby="" aria-hidden="true" style="display: none;"><img class="gwt-Image WLQO WN3P" src="https://impl.workday.com/wday/uiclient/static/gwt-desktop/update/WorkdayApp/8CB9E57BEDDE62E4F67DEB6E19F5308C.cache.png" draggable="false" alt=""><span class="WO3P" data-automation-id="moreLinkLabel" title="" aria-label="More (-4)"></span></div>
</div>
<div aria-readonly="true" class="wd-Text WAUY WMUY WJ3 WIKF WAKF" data-automation-id="compositeSubHeaderTwo" id="56$284555" dir="ltr">Supervisory Organization</div>
</div>
答案 0 :(得分:2)
也许您可以先在img
中找到ul
,然后指定preceding
和following
。
//ul//img[@title='Related Actions and Preview'][preceding::div[text()='Consulting Services'] and following::div[text()='Supervisory Organization']]
如果只想选择第一个,可以在括号之间包装表达式并使用索引。
(//ul//img[@title='Related Actions and Preview'][preceding::div[text()='Consulting Services'] and following::div[text()='Supervisory Organization']])[1]