Pages

Monday 6 February 2012

How can I instantiate HTMLUnitDriver?

The HTMLUnitDriver can be instantiated as below:


WebDriver driver = new HtmlUnitDriver(); // Instantiate the class - org.openqa.selenium.htmlunit.HtmlUnitDriver

Sample code:


package tests;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class HTMLUnitDriverSample {
public static void main(String[] args) {
// Instantiate the HTMLUnitDriver
WebDriver driver = new HtmlUnitDriver();

// Visit the Selenium-WebDriver FAQ site
driver.get("http://seleniumwebdriverfaq.tumblr.com/");

// Print the title of the page - It should print"Selenium-WebDriver FAQ's"
System.out.println("Title of the page is: " + driver.getTitle());

}
}

No comments:

Post a Comment