【发布时间】:2023-04-02 01:52:02
【问题描述】:
我有以下 html 代码并想按标签选择复选框:
<input type="checkbox" onclick="searchResult(this,'8')" id="catalog-8"/>
<label for="catalog-8">
my-assortment </label>
在上面的示例中,通过值“my-assortment”
我试过这个://label[containts('my-assortment')] 但它不起作用。
更确切地说,我想写这样的东西:
//input[@type='checkbox'] which has "id" of the value of "for"
in label[contains(., 'my-assortment')]
有人知道吗?
【问题讨论】:
-
你不能使用'catalog-8'的复选框'id'值来执行'FindBy'吗?
-
拼写正确
containts? -
[error] 元素 //label[contains('my-assortment')] 未找到
-
@Brian 那么它看起来怎么样?
-
您的问题是一个“Xpath”值。尝试用 ID 值替换该值。
标签: java user-interface selenium testing checkbox