Class OperaDriver

  • All Implemented Interfaces:
    org.openqa.selenium.HasCapabilities, org.openqa.selenium.html5.LocationContext, org.openqa.selenium.html5.WebStorage, org.openqa.selenium.interactions.HasInputDevices, org.openqa.selenium.interactions.Interactive, org.openqa.selenium.JavascriptExecutor, org.openqa.selenium.SearchContext, org.openqa.selenium.TakesScreenshot, org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator, org.openqa.selenium.WebDriver

    public class OperaDriver
    extends org.openqa.selenium.remote.RemoteWebDriver
    implements org.openqa.selenium.html5.LocationContext, org.openqa.selenium.html5.WebStorage
    A WebDriver implementation that controls a Blink-based Opera browser running on the local machine. This class is provided as a convenience for easily testing the Chrome browser. The control server which each instance communicates with will live and die with the instance. To avoid unnecessarily restarting the OperaDriver server with each instance, use a RemoteWebDriver coupled with the desired OperaDriverService, which is managed separately. For example:
    
    
     import static org.junit.Assert.assertEquals;
    
     import org.junit.*;
     import org.junit.runner.RunWith;
     import org.junit.runners.JUnit4;
     import org.openqa.selenium.opera.OperaDriverService;
     import org.openqa.selenium.remote.DesiredCapabilities;
     import org.openqa.selenium.remote.RemoteWebDriver;
    
     {@literal @RunWith(JUnit4.class)}
     public class OperaTest extends TestCase {
    
       private static OperaDriverService service;
       private WebDriver driver;
    
       {@literal @BeforeClass}
       public static void createAndStartService() {
         service = new OperaDriverService.Builder()
             .usingDriverExecutable(new File("path/to/my/operadriver.exe"))
             .usingAnyFreePort()
             .build();
         service.start();
       }
    
       {@literal @AfterClass}
       public static void createAndStopService() {
         service.stop();
       }
    
       {@literal @Before}
       public void createDriver() {
         driver = new RemoteWebDriver(service.getUrl(),
             DesiredCapabilities.opera());
       }
    
       {@literal @After}
       public void quitDriver() {
         driver.quit();
       }
    
       {@literal @Test}
       public void testGoogleSearch() {
         driver.get("http://www.google.com");
         WebElement searchBox = driver.findElement(By.name("q"));
         searchBox.sendKeys("webdriver");
         searchBox.quit();
         assertEquals("webdriver - Google Search", driver.getTitle());
       }
     }
     
    Note that unlike OperaDriver, RemoteWebDriver doesn't directly implement role interfaces such as LocationContext and WebStorage. Therefore, to access that functionality, it needs to be augmented and then cast to the appropriate interface.
    See Also:
    OperaDriverService.createDefaultService()
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.openqa.selenium.remote.RemoteWebDriver

        org.openqa.selenium.remote.RemoteWebDriver.RemoteTargetLocator, org.openqa.selenium.remote.RemoteWebDriver.RemoteWebDriverOptions, org.openqa.selenium.remote.RemoteWebDriver.When
      • Nested classes/interfaces inherited from interface org.openqa.selenium.WebDriver

        org.openqa.selenium.WebDriver.ImeHandler, org.openqa.selenium.WebDriver.Navigation, org.openqa.selenium.WebDriver.Options, org.openqa.selenium.WebDriver.TargetLocator, org.openqa.selenium.WebDriver.Timeouts, org.openqa.selenium.WebDriver.Window
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.openqa.selenium.html5.LocalStorage getLocalStorage()  
      org.openqa.selenium.html5.SessionStorage getSessionStorage()  
      org.openqa.selenium.html5.Location location()  
      void setFileDetector​(org.openqa.selenium.remote.FileDetector detector)  
      void setLocation​(org.openqa.selenium.html5.Location location)  
      • Methods inherited from class org.openqa.selenium.remote.RemoteWebDriver

        addVirtualAuthenticator, builder, close, execute, execute, execute, executeAsyncScript, executeScript, findElement, findElement, findElements, findElements, get, getCapabilities, getCommandExecutor, getCurrentUrl, getElementConverter, getErrorHandler, getExecuteMethod, getFileDetector, getKeyboard, getMouse, getPageSource, getScreenshotAs, getSessionId, getTitle, getWindowHandle, getWindowHandles, log, manage, navigate, perform, quit, removeVirtualAuthenticator, resetInputState, setCommandExecutor, setElementConverter, setErrorHandler, setFoundBy, setLogLevel, setSessionId, startSession, switchTo, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.openqa.selenium.JavascriptExecutor

        executeScript, getPinnedScripts, pin, unpin
    • Constructor Detail

      • OperaDriver

        @Deprecated
        public OperaDriver​(org.openqa.selenium.Capabilities capabilities)
        Deprecated.
        Creates a new OperaDriver instance. The capabilities will be passed to the chromedriver service.
        Parameters:
        capabilities - The capabilities required from the OperaDriver.
        See Also:
        OperaDriver(OperaDriverService, Capabilities)
      • OperaDriver

        public OperaDriver​(OperaDriverService service,
                           OperaOptions options)
        Creates a new OperaDriver instance with the specified options. The service will be started along with the driver, and shutdown upon calling RemoteWebDriver.quit().
        Parameters:
        service - The service to use.
        options - The options to use.
      • OperaDriver

        @Deprecated
        public OperaDriver​(OperaDriverService service,
                           org.openqa.selenium.Capabilities capabilities)
        Creates a new OperaDriver instance. The service will be started along with the driver, and shutdown upon calling RemoteWebDriver.quit().
        Parameters:
        service - The service to use.
        capabilities - The capabilities required from the OperaDriver.
    • Method Detail

      • setFileDetector

        public void setFileDetector​(org.openqa.selenium.remote.FileDetector detector)
        Overrides:
        setFileDetector in class org.openqa.selenium.remote.RemoteWebDriver
      • getLocalStorage

        public org.openqa.selenium.html5.LocalStorage getLocalStorage()
        Specified by:
        getLocalStorage in interface org.openqa.selenium.html5.WebStorage
      • getSessionStorage

        public org.openqa.selenium.html5.SessionStorage getSessionStorage()
        Specified by:
        getSessionStorage in interface org.openqa.selenium.html5.WebStorage
      • location

        public org.openqa.selenium.html5.Location location()
        Specified by:
        location in interface org.openqa.selenium.html5.LocationContext
      • setLocation

        public void setLocation​(org.openqa.selenium.html5.Location location)
        Specified by:
        setLocation in interface org.openqa.selenium.html5.LocationContext