I have added hardcode wait thread.sleep() in my below code. How to use explicit wait. I want to wait till \"username\" WebElement appear. My program is working
You have two options:
1- You can use implicity wait while initializing the driver.
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
2- Use explicty wait for the username field only:
WebDriverWait wait = new WebDriverWait(driver,30);
WebElement element = wait.until(
ExpectedConditions.visibilityOf(By.id(identifier)));