Pages

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

}

}

No comments:

Post a Comment