Implicit wait

We can pause a program for 10 secs by using below line of code

Thread.sleep(10000);

And if the web element is found well and good otherwise an error will be thrown.only problem with this command is we have to have to wait 10 secs even if the web element is found earlier.

So for this we use implicit wait instead.

The below command will implicitly wait for 25 seconds every time a driver. command is called.If element is found before 25 secs well and good otherwise error will be thrown only after 25 seconds Better than Thread.sleep which is called only once and where we do have to wait for the amount of time specified before a command is executed.So if element is found after 10 sec implicit wait will use that element and move forward and it will be not wait 25 secs.

driver.manage().timeouts().implicitlyWait(25,TimeUnit.SECONDS);

Two important things about this field are 1.This command should be the first line after the driver object is created.

Webdriver driver = new FirefoxDriver();}
 driver.manage().timeouts().implicitlyWait(25,TimeUnit.SECONDS);

2.This implicit wait command will be called every time a a driver.findElement command is fired.