【发布时间】:2018-04-08 00:25:58
【问题描述】:
我正在尝试单击与 UI 中的其他对象共享大量代码的按钮。这是按钮的代码:
<div class="ui green ok inverted button">
<i class="checkmark icon"></i> Yes </div>
这是按钮所在的模式:
<div class="actions"> <div class="ui red cancel inverted button">
<i class="remove icon"></i> No </div>
<div class="ui green ok inverted button">
<i class="checkmark icon"></i> Yes </div> <!--anchor--> </div>
这是我尝试但没有成功的示例:
By.xpath("//div[text()='green']")
我也尝试过“类”标签定位器和其他 div 类文本定位器,但每次都“找不到”。文本“green”和“Yes”是此特定对象的唯一唯一属性。
【问题讨论】:
-
能否分享一下按钮的完整html代码?
-
上面的 HTML 是用于按钮的所有代码。这是该按钮所属的模态的 HTML://*[@class="checkmark icon" and text()="Yes"] 试试这个这个定位器不起作用,虽然看起来应该可以!
标签: html css selenium xpath webdriver