我有以下xpath:
String button_selection_xpath = "//div[@aria-labelledby='ui-dialog-title-dialog-add']/div[@class='ui-dialog-buttonpane ui-widget-content ui-helper-clearfix']/div[@class='ui-dialog-buttonset']/button";
在div的aria-labelledby字段中,值可以是ui-dialog-title-dialog-add
或ui-dialog-title-dialog-comment
。
我尝试使用contains()函数创建一个语句以获取该字段:
String button_selection_xpath = "//div[contains(@aria-labelledby, 'ui-dialog-title-dialog')]/div[@class='ui-dialog-buttonpane ui-widget-content ui-helper-clearfix']/div[@class='ui-dialog-buttonset']/button";
但是当我使用contains()函数时,它找不到元素,最终会出现超时错误。我是否错误地使用了该功能,或者由于某种原因它在这种情况下是不适用的?
编辑:这是HTML:
<div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable"
style="display: block; z-index: 1004; outline: 0px none; height: auto; width: 700px;
top: 364px; left: 601.5px;" tabindex="-1" role="dialog"
aria-labelledby="ui-dialog-title-dialog-comment">
<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
<div class="ui-dialog-buttonset">
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false">
</button>
</div>
</div>
</div>