com.opera.core.systems
Class OperaDriver

java.lang.Object
  extended by org.openqa.selenium.remote.RemoteWebDriver
      extended by com.opera.core.systems.OperaDriver
All Implemented Interfaces:
org.openqa.selenium.HasCapabilities, org.openqa.selenium.HasInputDevices, org.openqa.selenium.internal.FindsByClassName, org.openqa.selenium.internal.FindsByCssSelector, org.openqa.selenium.internal.FindsById, org.openqa.selenium.internal.FindsByLinkText, org.openqa.selenium.internal.FindsByName, org.openqa.selenium.internal.FindsByTagName, org.openqa.selenium.internal.FindsByXPath, org.openqa.selenium.JavascriptExecutor, org.openqa.selenium.SearchContext, org.openqa.selenium.TakesScreenshot, org.openqa.selenium.WebDriver
Direct Known Subclasses:
OperaDesktopDriver

public class OperaDriver
extends org.openqa.selenium.remote.RemoteWebDriver
implements org.openqa.selenium.TakesScreenshot

OperaDriver is an implementation of the WebDriver interface that allows you to drive the Opera web browser. The driver uses the Scope protocol to communicate with Opera directly from Java. The implementation is vendor-supported and developed by Opera Software and volunteers.


Nested Class Summary
 class OperaDriver.OperaOptions
           
 class OperaDriver.OperaTimeouts
           
 class OperaDriver.OperaUtils
          Interface for accessing the browser's meta- and utility information.
 
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
 
Field Summary
protected  ScopeActions actionHandler
           
static String ARGUMENTS
          (String) Arguments to pass to Opera, separated by spaces.
static String AUTOSTART
          (Boolean) Whether to auto-start the Opera binary.
static String BACKEND
          Deprecated. 
static String BINARY
          (String) Path to the Opera binary to use.
protected  org.openqa.selenium.remote.DesiredCapabilities capabilities
           
protected  ICookieManager cookieManager
           
protected  ICoreUtils coreUtils
           
protected  IEcmaScriptDebugger debugger
           
static String DISPLAY
          (Integer) The X display to use.
protected  IOperaExec exec
           
static String GUESS_BINARY_PATH
          (Boolean) Whether to guess the path to Opera if it isn't set in opera.binary.
static String HOST
          (String) The host Opera should connect to.
static String LAUNCHER
          (String) Path to the launcher binary to use.
protected  Logger logger
           
static String LOGGING_FILE
          (String) Where to send the output of the logging.
static String LOGGING_LEVEL
          (String) How verbose the logging should be.
static String NO_QUIT
          (Boolean) Whether to quit Opera when OperaDriver is shut down.
static String NO_RESTART
          (Boolean) Whether to restart.
protected  Set<Integer> objectIds
           
static String OPERAIDLE
          (Boolean) Whether to use Opera's alternative implicit wait implementation.
static String PORT
          (Integer) The port to Opera should connect to.
static String PRODUCT
          (String) The product we are using, for example "desktop" or "core".
static String PROFILE
          (Object) Directory to use for the Opera profile.
protected  OperaRunner runner
           
protected  ScopeServices services
           
protected  IWindowManager windowManager
           
 
Constructor Summary
OperaDriver()
          Constructor that starts Opera with the default set of capabilities.
OperaDriver(org.openqa.selenium.Capabilities c)
          Starts Opera with the given set of desired capabilities.
OperaDriver(OperaProfile profile)
          Starts Opera with the given profile.
 
Method Summary
 void close()
           
 Object executeAsyncScript(String script, Object... args)
           
 Object executeScript(String script, Object... args)
           
 org.openqa.selenium.WebElement findElement(org.openqa.selenium.By by)
           
protected  org.openqa.selenium.WebElement findElement(String by, String using)
           
protected  org.openqa.selenium.WebElement findElement(String by, String using, OperaWebElement el)
          Find a single element using the selenium atoms.
 org.openqa.selenium.WebElement findElementByName(String using)
           
 List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By by)
           
protected  List<org.openqa.selenium.WebElement> findElements(String by, String using)
           
protected  List<org.openqa.selenium.WebElement> findElements(String by, String using, OperaWebElement el)
           
 List<org.openqa.selenium.WebElement> findElementsByName(String using)
           
 void get(String url)
           
 int get(String url, long timeout)
           
 org.openqa.selenium.Capabilities getCapabilities()
           
 String getCurrentUrl()
           
protected static org.openqa.selenium.Capabilities getDefaultCapabilities()
          Gets the default capabilities of OperaDriver.
protected  IOperaExec getExecService()
           
 org.openqa.selenium.Keyboard getKeyboard()
           
 org.openqa.selenium.Mouse getMouse()
           
 Set<String> getOperaActionList()
          Deprecated. 
 String getPageSource()
          Get the source of the last loaded page.
 String getPref(String section, String key)
          Deprecated. Please use preferences() instead
protected  ScopeServices getScopeServices()
           
<X> X
getScreenshotAs(org.openqa.selenium.OutputType<X> target)
           
protected  IEcmaScriptDebugger getScriptDebugger()
           
protected  Map<String,String> getServicesList()
           
 String getTitle()
           
 String getVersion()
          Returns the version number of driver.
 int getWindowCount()
           
 String getWindowHandle()
           
 Set<String> getWindowHandles()
           
protected  boolean hasTimeRemaining(long start)
           
protected  void init()
          Initialise all the Scope services that we need.
protected  boolean isOperaIdleAvailable()
          Whether idle functionality is available.
 List<String> listFrames()
          Gets a list of frames.
 OperaDriver.OperaOptions manage()
           
 org.openqa.selenium.WebDriver.Navigation navigate()
           
 void operaAction(String using, String... params)
          Deprecated.  
 OperaScopePreferences preferences()
          Returns an interface for manipulating the preferences in the currently attached Opera programmatically.
protected  List<org.openqa.selenium.WebElement> processElements(Integer id)
           
 void quit()
           
 ScreenShotReply saveScreenshot(long timeout, String... hashes)
          Takes a screenshot of the whole screen, including areas outside of the Opera browser window.
 String selftest(List<String> modules, long timeout)
          Executes selftests for the given module.
 void setPref(String section, String key, String value)
          Deprecated. Please use preferences() instead
protected  void setUseOperaIdle(boolean useIdle)
          Enable or disable idle functionality during runtime.
 org.openqa.selenium.WebDriver.TargetLocator switchTo()
           
 OperaDriver.OperaUtils utils()
          Gets the OperaDriver.OperaUtils interface which is used for accessing the browser's meta- and utility information, such as the operating system it's running on, its user agent string, &c.
protected  void waitForLoadToComplete()
           
 
Methods inherited from class org.openqa.selenium.remote.RemoteWebDriver
execute, execute, findElementByClassName, findElementByCssSelector, findElementById, findElementByLinkText, findElementByPartialLinkText, findElementByTagName, findElementByXPath, findElementsByClassName, findElementsByCssSelector, findElementsById, findElementsByLinkText, findElementsByPartialLinkText, findElementsByTagName, findElementsByXPath, getCommandExecutor, getElementConverter, getErrorHandler, getExecuteMethod, getFileDetector, getSessionId, log, setCommandExecutor, setElementConverter, setFileDetector, setLogLevel, setSessionId, startClient, startSession, stopClient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGING_LEVEL

public static final String LOGGING_LEVEL
(String) How verbose the logging should be. Available levels are: SEVERE (highest value), WARNING, INFO, CONFIG, FINE, FINER, FINEST (lowest value), ALL. Default is INFO.

See Also:
Constant Field Values

LOGGING_FILE

public static final String LOGGING_FILE
(String) Where to send the output of the logging. Default is to not write to file.

See Also:
Constant Field Values

BINARY

public static final String BINARY
(String) Path to the Opera binary to use. If not specified, OperaDriver will guess the path to your Opera installation (typically /usr/bin/opera or C:\Program Files\Opera\opera.exe).

See Also:
Constant Field Values

ARGUMENTS

public static final String ARGUMENTS
(String) Arguments to pass to Opera, separated by spaces. See opera -help for available command-line switches.

See Also:
Constant Field Values

HOST

public static final String HOST
(String) The host Opera should connect to. Unless you're starting Opera manually you won't need this.

See Also:
Constant Field Values

PORT

public static final String PORT
(Integer) The port to Opera should connect to. 0 = Random, -1 = Opera default (for use with Opera < 11.60).

See Also:
Constant Field Values

LAUNCHER

public static final String LAUNCHER
(String) Path to the launcher binary to use. The launcher is a gateway between OperaDriver and the Opera browser, and is being used for controlling the binary and taking external screenshots. If left blank, OperaDriver will use the launcher supplied with the package.

See Also:
Constant Field Values

PROFILE

public static final String PROFILE
(Object) Directory to use for the Opera profile. If an OperaProfile object that will be used when starting opera. If null a random temporary directory is used. If "", an empty string, then the default .autotest profile directory will be used (for backwards compatibility with Opera < 11.60).

See Also:
Constant Field Values

OPERAIDLE

public static final String OPERAIDLE
(Boolean) Whether to use Opera's alternative implicit wait implementation. It will use an in-browser heuristic to guess when a page has finished loading, allowing us with great accuracy tell whether there are any planned events in the document. This functionality is useful for very simple test cases, but not designed for real-world testing. It is disabled by default.

See Also:
Constant Field Values

DISPLAY

public static final String DISPLAY
(Integer) The X display to use. (Only works on *nix OSes.)

See Also:
Constant Field Values

AUTOSTART

public static final String AUTOSTART
(Boolean) Whether to auto-start the Opera binary. If false, OperaDriver will wait for a connection from the browser. Go to "opera:debug", enter the correct port number, and hit "Connect" to connect manually.

See Also:
Constant Field Values

NO_RESTART

public static final String NO_RESTART
(Boolean) Whether to restart.

See Also:
Constant Field Values

NO_QUIT

public static final String NO_QUIT
(Boolean) Whether to quit Opera when OperaDriver is shut down. If enabled, it will keep the browser running after the driver is shut down.

See Also:
Constant Field Values

GUESS_BINARY_PATH

public static final String GUESS_BINARY_PATH
(Boolean) Whether to guess the path to Opera if it isn't set in opera.binary.

See Also:
Constant Field Values

PRODUCT

public static final String PRODUCT
(String) The product we are using, for example "desktop" or "core".

See Also:
Constant Field Values

BACKEND

@Deprecated
public static final String BACKEND
Deprecated. 
(String) Rendering backend used by internal gogi builds of Opera. If null or an empty string, "software" is used by default. Warning: This is a temporary workaround for launcher not taking external window-only screenshots on Windows.

See Also:
Constant Field Values

capabilities

protected org.openqa.selenium.remote.DesiredCapabilities capabilities

runner

protected OperaRunner runner

debugger

protected IEcmaScriptDebugger debugger

exec

protected IOperaExec exec

windowManager

protected IWindowManager windowManager

coreUtils

protected ICoreUtils coreUtils

cookieManager

protected ICookieManager cookieManager

services

protected ScopeServices services

actionHandler

protected ScopeActions actionHandler

logger

protected final Logger logger

objectIds

protected Set<Integer> objectIds
Constructor Detail

OperaDriver

public OperaDriver()
Constructor that starts Opera with the default set of capabilities.


OperaDriver

public OperaDriver(OperaProfile profile)
Starts Opera with the given profile.

Parameters:
profile - the profile to start Opera with

OperaDriver

public OperaDriver(org.openqa.selenium.Capabilities c)
Starts Opera with the given set of desired capabilities.

Parameters:
c - a DesiredCapabilities object containing various settings for the driver and the browser
Method Detail

getDefaultCapabilities

protected static org.openqa.selenium.Capabilities getDefaultCapabilities()
Gets the default capabilities of OperaDriver.

Returns:
a DesiredCapabilities object with default settings

init

protected void init()
Initialise all the Scope services that we need. For testing override this method.


getServicesList

protected Map<String,String> getServicesList()
Returns:
a map of service names to the minimum versions we require.

getCapabilities

public org.openqa.selenium.Capabilities getCapabilities()
Specified by:
getCapabilities in interface org.openqa.selenium.HasCapabilities
Overrides:
getCapabilities in class org.openqa.selenium.remote.RemoteWebDriver

quit

public void quit()
Specified by:
quit in interface org.openqa.selenium.WebDriver
Overrides:
quit in class org.openqa.selenium.remote.RemoteWebDriver

get

public void get(String url)
Specified by:
get in interface org.openqa.selenium.WebDriver
Overrides:
get in class org.openqa.selenium.remote.RemoteWebDriver

get

public int get(String url,
               long timeout)

getCurrentUrl

public String getCurrentUrl()
Specified by:
getCurrentUrl in interface org.openqa.selenium.WebDriver
Overrides:
getCurrentUrl in class org.openqa.selenium.remote.RemoteWebDriver

close

public void close()
Specified by:
close in interface org.openqa.selenium.WebDriver
Overrides:
close in class org.openqa.selenium.remote.RemoteWebDriver

findElement

public org.openqa.selenium.WebElement findElement(org.openqa.selenium.By by)
Specified by:
findElement in interface org.openqa.selenium.SearchContext
Specified by:
findElement in interface org.openqa.selenium.WebDriver
Overrides:
findElement in class org.openqa.selenium.remote.RemoteWebDriver

findElement

protected org.openqa.selenium.WebElement findElement(String by,
                                                     String using)
Overrides:
findElement in class org.openqa.selenium.remote.RemoteWebDriver

findElement

protected org.openqa.selenium.WebElement findElement(String by,
                                                     String using,
                                                     OperaWebElement el)
Find a single element using the selenium atoms.

Parameters:
by - how to find the element, strings defined in RemoteWebDriver
using - the value to use to find the element
el - the element to search within
Returns:
an element

findElements

public List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By by)
Specified by:
findElements in interface org.openqa.selenium.SearchContext
Specified by:
findElements in interface org.openqa.selenium.WebDriver
Overrides:
findElements in class org.openqa.selenium.remote.RemoteWebDriver

findElements

protected List<org.openqa.selenium.WebElement> findElements(String by,
                                                            String using)
Overrides:
findElements in class org.openqa.selenium.remote.RemoteWebDriver

findElements

protected List<org.openqa.selenium.WebElement> findElements(String by,
                                                            String using,
                                                            OperaWebElement el)

getPageSource

public String getPageSource()
Get the source of the last loaded page. The source will be of the modified DOM, not the original HTML. The page source returned is a representation of the underlying DOM: do not expect it to be formatted or escaped in the same way as the response sent from the web server.

Specified by:
getPageSource in interface org.openqa.selenium.WebDriver
Overrides:
getPageSource in class org.openqa.selenium.remote.RemoteWebDriver
Returns:
source code of document

getTitle

public String getTitle()
Specified by:
getTitle in interface org.openqa.selenium.WebDriver
Overrides:
getTitle in class org.openqa.selenium.remote.RemoteWebDriver

getWindowHandle

public String getWindowHandle()
Specified by:
getWindowHandle in interface org.openqa.selenium.WebDriver
Overrides:
getWindowHandle in class org.openqa.selenium.remote.RemoteWebDriver

getWindowHandles

public Set<String> getWindowHandles()
Specified by:
getWindowHandles in interface org.openqa.selenium.WebDriver
Overrides:
getWindowHandles in class org.openqa.selenium.remote.RemoteWebDriver

getWindowCount

public int getWindowCount()

switchTo

public org.openqa.selenium.WebDriver.TargetLocator switchTo()
Specified by:
switchTo in interface org.openqa.selenium.WebDriver
Overrides:
switchTo in class org.openqa.selenium.remote.RemoteWebDriver

findElementByName

public org.openqa.selenium.WebElement findElementByName(String using)
Specified by:
findElementByName in interface org.openqa.selenium.internal.FindsByName
Overrides:
findElementByName in class org.openqa.selenium.remote.RemoteWebDriver

findElementsByName

public List<org.openqa.selenium.WebElement> findElementsByName(String using)
Specified by:
findElementsByName in interface org.openqa.selenium.internal.FindsByName
Overrides:
findElementsByName in class org.openqa.selenium.remote.RemoteWebDriver

navigate

public org.openqa.selenium.WebDriver.Navigation navigate()
Specified by:
navigate in interface org.openqa.selenium.WebDriver
Overrides:
navigate in class org.openqa.selenium.remote.RemoteWebDriver

manage

public OperaDriver.OperaOptions manage()
Specified by:
manage in interface org.openqa.selenium.WebDriver
Overrides:
manage in class org.openqa.selenium.remote.RemoteWebDriver

getScreenshotAs

public <X> X getScreenshotAs(org.openqa.selenium.OutputType<X> target)
                  throws org.openqa.selenium.WebDriverException
Specified by:
getScreenshotAs in interface org.openqa.selenium.TakesScreenshot
Throws:
org.openqa.selenium.WebDriverException

executeScript

public Object executeScript(String script,
                            Object... args)
Specified by:
executeScript in interface org.openqa.selenium.JavascriptExecutor
Overrides:
executeScript in class org.openqa.selenium.remote.RemoteWebDriver

executeAsyncScript

public Object executeAsyncScript(String script,
                                 Object... args)
Specified by:
executeAsyncScript in interface org.openqa.selenium.JavascriptExecutor
Overrides:
executeAsyncScript in class org.openqa.selenium.remote.RemoteWebDriver

getKeyboard

public org.openqa.selenium.Keyboard getKeyboard()
Specified by:
getKeyboard in interface org.openqa.selenium.HasInputDevices
Overrides:
getKeyboard in class org.openqa.selenium.remote.RemoteWebDriver

getMouse

public org.openqa.selenium.Mouse getMouse()
Specified by:
getMouse in interface org.openqa.selenium.HasInputDevices
Overrides:
getMouse in class org.openqa.selenium.remote.RemoteWebDriver

listFrames

public List<String> listFrames()
Gets a list of frames.

Returns:
list of frames

saveScreenshot

public ScreenShotReply saveScreenshot(long timeout,
                                      String... hashes)
Takes a screenshot of the whole screen, including areas outside of the Opera browser window.

Parameters:
timeout - the number of milliseconds to wait before taking the screenshot
hashes - A previous screenshot MD5 hash. If it matches the hash of this screenshot then no image data is returned.
Returns:
a ScreenShotReply object

getVersion

public String getVersion()
Returns the version number of driver.

Returns:
version number

preferences

public OperaScopePreferences preferences()
Returns an interface for manipulating the preferences in the currently attached Opera programmatically. Some changes might require Opera to restart before the changes take affect. The available preferences are found in opera:config.

Returns:
methods for interacting with preferences

setPref

@Deprecated
public void setPref(String section,
                               String key,
                               String value)
Deprecated. Please use preferences() instead

Sets the given preference information. If a previous preference with the same section and key names exist, it will be replaced by the given preference.

Parameters:
section - the section name, can be case-insensitive
key - the key name, can be case-insensitive
value - the new value (will be treated as a String in Opera

getPref

@Deprecated
public String getPref(String section,
                                 String key)
Deprecated. Please use preferences() instead

Returns the preference with the given section and key values.

Parameters:
section - the section name, can be case-insensitive
key - the key name, can be case-insensitive
Returns:
the preference requested

utils

public OperaDriver.OperaUtils utils()
Gets the OperaDriver.OperaUtils interface which is used for accessing the browser's meta- and utility information, such as the operating system it's running on, its user agent string, &c.

Returns:
utility methods for Opera

selftest

public String selftest(List<String> modules,
                       long timeout)
Executes selftests for the given module.

Parameters:
modules - the list of modules to run selftests for
timeout - the time out before aborting the operation
Returns:
results of the selftests

operaAction

@Deprecated
public void operaAction(String using,
                                   String... params)
Deprecated. 

Performs a special action, such as setting an Opera preference. For a list of actions call getOperaActionList().

Parameters:
using - the action to perform.
params - parameters to pass to the action call

getOperaActionList

@Deprecated
public Set<String> getOperaActionList()
Deprecated. 


getScriptDebugger

protected IEcmaScriptDebugger getScriptDebugger()

getExecService

protected IOperaExec getExecService()

getScopeServices

protected ScopeServices getScopeServices()

hasTimeRemaining

protected boolean hasTimeRemaining(long start)

processElements

protected List<org.openqa.selenium.WebElement> processElements(Integer id)

waitForLoadToComplete

protected void waitForLoadToComplete()
                              throws ResponseNotReceivedException
Throws:
ResponseNotReceivedException

isOperaIdleAvailable

protected boolean isOperaIdleAvailable()
Whether idle functionality is available. Note that this is not the same as whether the idle functionality is enabled.

Returns:
true if idle is available, false otherwise

setUseOperaIdle

protected void setUseOperaIdle(boolean useIdle)
Enable or disable idle functionality during runtime.

Parameters:
useIdle - true if idle should be switched on, false if it should be switched off


Copyright © 2012. All Rights Reserved.