【问题标题】:Selenide doesn't find the Web elementSelenide 找不到 Web 元素
【发布时间】:2017-11-03 15:08:29
【问题描述】:

有人可以帮助了解通过 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"))

【问题讨论】:

    标签: java selenide


    【解决方案1】:

    如果你需要强壮,你可以

       $(By.xpath("//strong[contains(text(),'SMS')]"))
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

        你可以试试:

        $(byText("Current method:")).shouldBe(Condition.exist);
        

        【讨论】:

          【解决方案4】:

          使用硒-> findElement(By.xpath("//div[contains(text(), '当前方法')]/strong"));

          使用硒化物-> $(By.xpath("//div[contains(text(), '当前方法')]/strong"));

          这两种方法可以用在硒和硒化物中。方法不是特定于硒或硒化物的

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2018-09-21
            • 2016-08-09
            • 2021-10-07
            • 2023-03-18
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多