0

有人可以帮助了解通过 Selenide 进行元素搜索有什么问题。

我有这样的 HTML 代码:

<div>
  Current method: 
  <strong>
    SMS
  </strong>
</div>

Selenium 发现元素抛出这个 xpath

findElement(By.xpath("//div[contains(. , \"Current method\")]/strong"))

但是 Selenide 使用相同的定位器返回 ElementNotFound 异常

$(By.xpath("//div[contains(. , \"Current method\")]/strong"))
4

4 回答 4

1

您可以选择以下选项。$("strong:contains('SMS')");Using css selectors method

于 2018-01-07T16:16:23.570 回答
1

如果你需要强壮,你可以

   $(By.xpath("//strong[contains(text(),'SMS')]"))
于 2017-11-24T12:27:09.823 回答
0

你可以试试 :

$(byText("Current method:")).shouldBe(Condition.exist);
于 2017-11-08T13:08:42.113 回答
0

使用 Selenium-> findElement(By.xpath("//div[contains(text(), 'Current method')]/strong"));

使用 Selenide-> $(By.xpath("//div[contains(text(), 'Current method')]/strong"));

这两种方法可用于硒以及硒化物。方法不特定于硒或硒化物

于 2017-11-24T15:59:34.640 回答