Pages

Monday 6 February 2012

How can I instantiate FirefoxDriver?

The FirefoxDriver can be instantiated as below:


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

Sample code(Java Binding):


package tests;

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

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

// 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());

//Close the browser window
driver.close();

//Quit the driver
driver.quit();
}
}

1 comment: