The different WebDriver Wait statements that can be useful for an effective scripting are listed below. It is a bad practice to use Thread.sleep() command because it makes the script slow and doesn't work with unpredictable environments. ImplicitlyWait Command Purpose: We can tell Selenium that we would like it to wait for a certain amount of time before throwing an exception that it cannot find the element on the page. We should note that implicit waits will be in place for the entire time the browser is open. This means that any search for elements on the page could take the time the implicit wait is set for. WebDriver driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get("http://url_that_delays_loading"); WebElement myDynamicElement = driver.findElement(By.id("myDynamicElement")); FluentWait Command Purpose: Each FluentWait instance defines the maximum amount of time to wait for a condition,...
Write your first selenium program in less than an hour! Follow for updates!