wait explixit code example
Example 1: how to waitselenium webelement java
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.elementToBeClickable(By.id("button1")));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("text_box1")));
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("text_box1")));
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Example 2: explicit waits selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Firefox()
driver.get("http://somedomain/url_that_delays_loading")
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "myDynamicElement"))
)
finally:
driver.quit()