【问题标题】:How to check if an element is visible with WebDriver - eternal loading如何使用 WebDriver 检查元素是否可见 - 永久加载
【发布时间】:2022-07-07 23:26:18
【问题描述】:

我正在测试一个关闭窗口的按钮。然后当我点击按钮时,我需要检查窗口是否关闭。

我创建了这个方法:

enter code here




public boolean isElementPresent(String locatorKey) {
    try {
        driver.findElement(By.xpath(locatorKey));
        return true;
    } catch (org.openqa.selenium.NoSuchElementException e) {
        Assert.assertFalse((isElementPresent(String.valueOf(By.xpath(locatorKey)))));
        return false;
    }
}





enter code here

但它不起作用。 Selenium 一直在加载最后一步,最后显示这个错误

命令:[8139ce6f8c35642a752d7fbedb186ec6, findElement {using=xpath, value=By.xpath: By.xpath: By.xpath: By.xpath: By.xpath: By.xpath: By.xpath: By.xpath: By. xpath: By.xpath:

【问题讨论】:

    标签: java selenium selenium-webdriver selenium-java


    【解决方案1】:

    如果您使用 Java,请考虑使用 Selenide。

    $x("your xpath").should(disappear);
    

    这就是您对 Selenide 所做的一切。

    https://selenide.org/

    【讨论】:

      猜你喜欢
      • 2011-02-08
      • 1970-01-01
      • 2012-06-11
      • 2017-01-01
      • 2023-03-04
      • 2012-07-08
      • 1970-01-01
      • 2021-02-19
      • 1970-01-01
      相关资源
      最近更新 更多