我很难找到需要单击的输入(复选框)元素的xpath。我正在尝试使用另一个span元素来定位它。元素包含角度属性,不知道这是否重要?
元素的结构如下:
<div _ngcontent-c6="" class="py-1" style="">
<input _ngcontent-c6="" type="checkbox">
<span _ngcontent-c6="" class="pl-2">Company name</span>
</div>我可以使用下面的xpath找到span元素:
"//span[text() = '" + SearchInput + "']"但是我很难点击下面的input元素。下面的xpath对我不起作用:
"//span[text() = '" + SearchInput + "']/following-sibling::input"
"//span[text() = '" + SearchInput + "']/following-sibling::input[@type = 'checkbox']"我到处寻找答案,但似乎找不到一个适合我的答案。如果任何人能帮助我或给我一个真正适合我的问题,我将不胜感激!
发布于 2019-02-15 17:06:11
可能有一种更好的方法,但下面的方法对我来说是有效的。搜索具有子对象作为span的div并获取该div的input子对象
//div[span[text() = 'Company name']]/inputhttps://stackoverflow.com/questions/54705272
复制相似问题