PageLoadTimeOut in Selenium

package webdriver;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class PageLoad {
	
	static WebDriver driver;

	public static void main(String[] args) {
		
		driver = new FirefoxDriver();
		
		driver.manage().window().maximize();
		
		driver.get("http://facebook.com");
		
		driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
		
		driver.quit();
		
	}

}

The above code will verify the page is getting load with expected time(5 Sec) or not.  If Page will not load completely within the given time then selenium will throw the TimeoutException in the console.

Leave a Reply

Your email address will not be published. Required fields are marked *