如何编写 xpath 以选择没有 aria-hidden= "true" 的项目?



我需要单击"Cancel"按钮。因此,我尝试编写一个看起来像这样的X-Path:

//button[text()='Cancel']

但是,确定了两个元素,因为两个元素与下面的条件匹配,尽管其中一个元素被隐藏:

<button type="button" class="gwt-Button button_action_id_9135994370013188418_9135995360013188733_compositepopup_3 TableCtrl-button cancel-button">Cancel</button>
<button type="button" class="gwt-Button button_action_id_9149469526113774095_9149539697213772969 TableCtrl-button cancel-button" aria-hidden="true" style="display: none;">Cancel</button>

有没有一种方法可以识别没有诸如'aria-hidden'之类的标签的元素?

尝试使用下面的xpath以匹配所需(不是隐藏的按钮(:

//button[text()='Cancel' and not(@aria-hidden='true')]

相关内容

最新更新