【发布时间】:2018-05-25 17:13:33
【问题描述】:
我的 HTML 代码片段:
<span class="c-extselect__label js-label">Some text 1</span>
<span class="c-extselect__label js-label">Some text 2</span>
我想编写 xPath,点击其中一个跨度。
我知道这行得通:
browser.click(`//span[contains(text(), "Some text 1")]`);
但我想根据“变量”点击一次“Some text 1”和嵌套时间将等于“Some text 2”。
我试过了:
browser.click(`//span[contains(text(), ${item})]`);
但它不起作用。
【问题讨论】:
-
你可以试试:
//span[contains(text(), '${item}')]
标签: javascript xpath webdriver-io