I am checking that under some conditions button
element shouldn't be displayed.
I use the following code but it lasts for 40 seconds. I need it to be quicker.
try {
addAnotherScenarioButton.click();
return true;
} catch (org.openqa.selenium.NoSuchElementException e) {
log.debug("Creating scenario button is not displayed");
return false;
}
Here is the log result:
13:26:33 DEBUG: Checking visibility for creating scenario button
13:27:13 DEBUG: Creating scenario button is not displayed
You can use
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("Your xpath"));
Or
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.or(
ExpectedConditions.visibilityOfElementLocated(By.xpath("Your xpath")),
ExpectedConditions.visibilityOfElementLocated(By.xpath("Your xpath"))
));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.