Pages

Showing posts with label Instantiate. Show all posts
Showing posts with label Instantiate. Show all posts

Wednesday, 8 February 2012

How can I instantiate OperaDriver?

The OperaDriver can be instantiated as below:


WebDriver driver = new OperaDriver(); // Instantiate the class - com.opera.core.systems.OperaDriver

Sample code(Java Binding - Windows):


package tests;

import org.openqa.selenium.WebDriver;
import com.opera.core.systems.OperaDriver;

public class OperaDriverSample {

public static void main(String[] argv) throws Exception {

//Opera exe should be in %PROGRAMFILES%Operaopera.exe

// Instantiate the OperaDriver
WebDriver driver = new OperaDriver();

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

}

}

Tuesday, 7 February 2012

How can I instantiate InternetExplorerDriver?

The InternetExplorerDriver can be instantiated as below:


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

Sample code(Java Binding):


package tests;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

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

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

}
}

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

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

}
}