Implicitlywait command issue
I have added implicitlyWaiwait after success full login, but it is not waiting for 30seconds it is directly clicking on logout. This is code ( from your website ). Is this the wrong way to add implicitlyWaiwait command. Please suggest me.
driver.findElement(By.id("pwd")).sendKeys("Test@123"); // Now submit the form. WebDriver will find the form for us from the element driver.findElement(By.id("login")).click(); // Print a Log In message to the screen System.out.println(" Login Successfully, now it is the time to Log Off buddy after 30 seconds."); // Find the element that's ID attribute is 'account_logout' (Log Out) driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.findElement (By.xpath(".//*[@id='account_logout']/a")).click(); // Close the driver driver.quit(); } }
Both of the above two chaps are correct about Implicit Wait and Thread Sleep. But still if you want to know more about wait commands and different wait, you can follow the link:
You can give thread sleep command. It will delay the execution for certain seconds. The syntax for thread sleep is Thread.sleep(any number). It will take the numbers in milli seconds. In your case, for 30 seconds you can specify as Thread.sleep(30000L);. I think it may help you.
In Case of this it Will Wait Maximum 30 seconds for elements
but if Element is Found Before that 30-second Duration it will Perform Operation on that
But if Element is not Found in 30 sec it will throw a Element not Found Exception After 30 sec
I hope this is Clear to You