Please anyone explain with an example how Implicit wait can be used in Selenium Webdriver

+1 vote
Please anyone explain with an example how Implicit wait can be used in Selenium Webdriver?
Jul 23, 2019 in Selenium by Kartik
1,046 views

2 answers to this question.

+1 vote

Hello Kartik, following piece of code can help you in understanding Implicit wait and how it can be used in Selenium:

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.testng.annotations.Test;

public class VerifyTitle

{

                @Test

                public void verifyPageTitle()

                {

                                WebDriver driver=new FirefoxDriver();

                                driver.manage().window().maximize();

                                driver.get("http://www.facebook.com");

                                // Specify implicit wait of 30 seconds                                   
                                 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

                              // No login id is present on Webpage so this will fail our script.
                                driver.findElement(By.id("login")).sendKeys(" Abha Rathour");

                }

}
answered Jul 23, 2019 by Abha
• 28,140 points
+1 vote
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
answered Dec 24, 2019 by Sandy
Thanks @Sandy

This one line was all I needed.
hello @Sandy! I hope you are doing fine. Please do register at Edureka Community and earn credits for all your contribution(asking a question, answering, commenting or even upvoting)