Wednesday 9 November 2016

Explicit wait and Implicit wait

Explicit wait syntax
WebDriver driver=new FirefoxDriver();
WebDriverWait wait=new WebDriverWait(driver,10);
wait.untill(ExpectedConditions.VisibilityofelementLocated(By.id(“username”)));
system.out.println(“success”);

It will explicitly wait for the element whose id is “username” for 10 sec.If it is visible then success message is displayed else an error or exception will be generated.

Implicitly Wait syntax
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

It will implicitly wait for the element for a defined amount of time before raising an exception that element cannot be found.

0 comments: