-1

私はJavatrycatch. 要素が存在しない場合は、次のステップにスキップする必要があります

tryブロック内で次のことを試しました。

driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

しかし、次のエラーが発生しました:

org.openqa.selenium.remote.ErrorHandler$UnknownServerException: 要素は現在表示されていないため、操作できない可能性があります`

4

1 に答える 1

0

以下のようなものを試すことができます:

WebDriverWait wait = new WebDriverWait(driver,20);

try {
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("id of the element to be located")));
    return SUCCESS;
} catch (NoSuchElementException exception) {
    return FAILURE;
}

return の場合はSUCCESS次の行を実行し、それ以外の場合はスキップします。

于 2016-10-14T08:53:27.723 に答える