Selenium / Appium显式等待visibilityOf condtion不会抛出TimeoutException

时间:2018-02-08 12:24:07

标签: java selenium selenium-webdriver appium

只是想了解下面的代码什么时候会抛出任何异常,如果或者爆发。

目前,它一直在等待元素可见。但我认为它将在10秒内抛出TimeOutException,因为它已被传递

WebDriverWait webDriverWait = new WebDriverWait(driver,10);
try {
    webDriverWait.until(ExpectedConditions.visibilityOf(element));
} catch (TimeoutException e) {
    logIt(e);
}

或者这是visibilityOf方法的设计吗?无限期等待,直到元素存在/可见?那么在WebDriverWait构造函数中使用超时有什么用呢?

虽然我长期致力于硒,但我对此并不感到困惑。

1 个答案:

答案 0 :(得分:0)

我正在使用新的TestProject free SDK进行网络自动化。

By by;
by = By.xpath("//div[@class='example']");

以及以下方法之一:

    driver.testproject().isPresent(by, 10);
    driver.testproject().isVisible(by, 10);
    driver.testproject().isClickable(by, 10);
    driver.testproject().isInvisible(by, 10);
    driver.testproject().clickIfVisible(by, 10);

您还可以在方法之前添加布尔值。 例如,一旦元素状态变为可见,则值将自动检索“ true”。 如果超时前状态未更改,则为false

boolean result;
result =   driver.testproject().isVisible(by, 10);

您将不会获得任何例外