Thread.sleep() method is used to pause the for defined time. Time is defined in milliseconds for this method.
Here is the very basic program to use Thread.sleep() method in Selenium Webdriver script.
Here is the very basic program to use Thread.sleep() method in Selenium Webdriver script.
Java Source code:
package com.helloselenium.selenium.test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class OpenHelloSeleniumBlog{ public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("http://helloselenium.blogspot.com"); try{ Thread.sleep(5000); }catch (InterruptedException ie1) { ie1.printStackTrace(); } driver.quit(); } }
Detailed explanation for the above program is as follows:
Following code is the required packages for Selenium Webdriver.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
Following code is to initialize the Firefox driver.
WebDriver driver = new FirefoxDriver();
driver.navigate().to("http://helloselenium.blogspot.com");
Following code is to open the hello selenium blog in browser.
driver.get("http://helloselenium.blogspot.com");
Thread.sleep(5000);
driver.quit();
driver.close();
1 Comments
great
ReplyDeleteWhat would you like to add in my list? I look forward to reading your comments below.