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.OperaUtils
           
 
Nested classes/interfaces inherited from class org.openqa.selenium.remote.RemoteWebDriver
org.openqa.selenium.remote.RemoteWebDriver.RemoteMouse, org.openqa.selenium.remote.RemoteWebDriver.RemoteTargetLocator, org.openqa.selenium.remote.RemoteWebDriver.RemoteWebDriverOptions
 
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
 
Field Summary
protected  ScopeActions actionHandler
           
static java.lang.String ARGUMENTS
          (String) Arguments to pass to Opera, separated by spaces.
static java.lang.String AUTOSTART
          (Boolean) Whether to auto-start the Opera binary.
static java.lang.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 java.lang.String DISPLAY
          (Integer) The X display to use.
protected  IOperaExec exec
           
static java.lang.String GUESS_BINARY_PATH
          (Boolean) Whether to guess the path to Opera if it isn't set in opera.binary.
static java.lang.String HOST
          (String) The host Opera should connect to.
static java.lang.String LAUNCHER
          (String) Path to the launcher binary to use.
protected  java.util.logging.Logger logger
           
static java.lang.String LOGGING_FILE
          (String) Where to send the output of the logging.
static java.lang.String LOGGING_LEVEL
          (String) How verbose the logging should be.
static java.lang.String NO_QUIT
          (Boolean) Whether to quit Opera when OperaDriver is shut down.
static java.lang.String NO_RESTART
          (Boolean) Whether to restart.
protected  java.util.Set<java.lang.Integer> objectIds
           
static java.lang.String OPERAIDLE
          (Boolean) Whether to use Opera's alternative implicit wait implementation.
protected  OperaRunner operaRunner
           
static java.lang.String PORT
          (Integer) The port to Opera should connect to.
protected  IPrefs prefs
           
static java.lang.String PRODUCT
          (String) The profile configuration we are using, for example "desktop" or "core-gogi".
static java.lang.String PROFILE
          (String) Directory to use for the Opera profile.
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)
          Constructor that starts Opera with a set of desired capabilities.
OperaDriver(OperaDriverSettings settings)
          Deprecated. 
 
Method Summary
 void close()
           
protected  java.lang.String escapeJsString(java.lang.String string)
          Escape characters for safe insertion in a Javascript string contained by double quotes (").
 void executeActions(OperaAction action)
          Deprecated.  
 java.lang.Object executeAsyncScript(java.lang.String script, java.lang.Object... args)
           
 java.lang.Object executeScript(java.lang.String script, java.lang.Object... args)
           
 org.openqa.selenium.WebElement findElement(org.openqa.selenium.By by)
           
protected  org.openqa.selenium.WebElement findElement(java.lang.String by, java.lang.String using)
           
protected  org.openqa.selenium.WebElement findElement(java.lang.String by, java.lang.String using, OperaWebElement el)
          Find a single element using the selenium atoms.
 org.openqa.selenium.WebElement findElementByName(java.lang.String using)
           
 java.util.List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By by)
           
protected  java.util.List<org.openqa.selenium.WebElement> findElements(java.lang.String by, java.lang.String using)
           
protected  java.util.List<org.openqa.selenium.WebElement> findElements(java.lang.String by, java.lang.String using, OperaWebElement el)
           
 java.util.List<org.openqa.selenium.WebElement> findElementsByName(java.lang.String using)
           
 void get(java.lang.String url)
           
 int get(java.lang.String url, long timeout)
           
 org.openqa.selenium.Capabilities getCapabilities()
           
 java.lang.String getCurrentUrl()
           
static org.openqa.selenium.Capabilities getDefaultCapabilities()
          Gets the default capabilities of OperaDriver.
 java.lang.String getDefaultPref(java.lang.String section, java.lang.String key)
          Gets the default value of the requested preference.
protected  IOperaExec getExecService()
           
 org.openqa.selenium.Keyboard getKeyboard()
           
 org.openqa.selenium.Mouse getMouse()
           
 OperaRunner getOperaRunner()
          Deprecated.  
 java.lang.String getPageSource()
          Get the source of the last loaded page.
 java.lang.String getPref(java.lang.String section, java.lang.String key)
          Get the value of the requested preference.
protected  ScopeServices getScopeServices()
           
<X> X
getScreenshotAs(org.openqa.selenium.OutputType<X> target)
           
protected  IEcmaScriptDebugger getScriptDebugger()
           
protected  java.util.Map<java.lang.String,java.lang.String> getServicesList()
           
 java.lang.String getTitle()
           
 java.lang.String getVersion()
          Returns the version number of driver.
 int getWindowCount()
           
 java.lang.String getWindowHandle()
           
 java.util.Set<java.lang.String> getWindowHandles()
           
protected  IWindowManager getWindowManager()
           
protected  void init()
          For testing override this method.
 boolean isJavascriptEnabled()
          Is JavaScript enables in this driver?
 boolean isOperaIdleAvailable()
           
 void key(java.lang.String key)
          Presses and releases the given key.
 void keyDown(java.lang.String key)
          Presses and holds the given key.
 void keyUp(java.lang.String key)
          Releases the given key.
 java.util.Map<java.lang.String,java.util.Map<java.lang.String,PrefsProtos.Pref>> listAllPrefs()
          Returns a Map of sections names mapping to a Map of preference names mapping to Pref objects.
 java.util.List<java.lang.String> listFrames()
           
 java.util.Map<java.lang.String,PrefsProtos.Pref> listPrefs(boolean sort, java.lang.String section)
          Returns a Map of preference names to preferences in the requested section.
 org.openqa.selenium.WebDriver.Options manage()
           
 org.openqa.selenium.WebDriver.Navigation navigate()
           
 void operaAction(java.lang.String using, java.lang.String... params)
          Performs a special action, such as setting an Opera preference.
protected  java.util.List<org.openqa.selenium.WebElement> processElements(java.lang.Integer id)
           
 void quit()
           
 void releaseKeys()
          Releases all the currently pressed keys.
 ScreenShotReply saveScreenshot(long timeout, java.lang.String... hashes)
          Takes a screenshot of the whole screen, including areas outside of the Opera browser window.
 java.lang.String selftest(java.util.List<java.lang.String> modules, long timeout)
           
 void setPref(java.lang.String section, java.lang.String key, java.lang.String value)
          Set the value of a preference using section and key as locators.
 void setUseOperaIdle(boolean useIdle)
           
 org.openqa.selenium.WebDriver.TargetLocator switchTo()
           
 void type(java.lang.String using)
          Types the given string as-is in to the browser window.
 Utils utils()
           
 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, getSessionId, log, newRemoteWebElement, setCommandExecutor, setElementConverter, 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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.String PORT
(Integer) The port to Opera should connect to. 0 = Random, -1 = Opera default (for use with Opera < 12).

See Also:
Constant Field Values

LAUNCHER

public static final java.lang.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 java.lang.String PROFILE
(String) Directory to use for the Opera profile. If null a random temporary directory is used. If "", an empty string, then the default autotest profile directory is used.

See Also:
Constant Field Values

OPERAIDLE

public static final java.lang.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 java.lang.String DISPLAY
(Integer) The X display to use. (Only works on *nix OSes.)

See Also:
Constant Field Values

AUTOSTART

public static final java.lang.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 java.lang.String NO_RESTART
(Boolean) Whether to restart.

See Also:
Constant Field Values

NO_QUIT

public static final java.lang.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 java.lang.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 java.lang.String PRODUCT
(String) The profile configuration we are using, for example "desktop" or "core-gogi".

See Also:
Constant Field Values

capabilities

protected org.openqa.selenium.remote.DesiredCapabilities capabilities

operaRunner

protected OperaRunner operaRunner

debugger

protected IEcmaScriptDebugger debugger

exec

protected IOperaExec exec

prefs

protected IPrefs prefs

windowManager

protected IWindowManager windowManager

coreUtils

protected ICoreUtils coreUtils

cookieManager

protected ICookieManager cookieManager

services

protected ScopeServices services

actionHandler

protected ScopeActions actionHandler

logger

protected final java.util.logging.Logger logger

objectIds

protected java.util.Set<java.lang.Integer> objectIds
Constructor Detail

OperaDriver

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


OperaDriver

@Deprecated
public OperaDriver(OperaDriverSettings settings)
Deprecated. 


OperaDriver

public OperaDriver(org.openqa.selenium.Capabilities c)
Constructor that starts Opera with a set of desired capabilities.

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

getDefaultCapabilities

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

Returns:
a DesiredCapabilities object with default settings

init

protected void init()
For testing override this method.


getServicesList

protected java.util.Map<java.lang.String,java.lang.String> getServicesList()

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(java.lang.String url)
Specified by:
get in interface org.openqa.selenium.WebDriver
Overrides:
get in class org.openqa.selenium.remote.RemoteWebDriver

get

public int get(java.lang.String url,
               long timeout)

getCurrentUrl

public java.lang.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(java.lang.String by,
                                                     java.lang.String using)
Overrides:
findElement in class org.openqa.selenium.remote.RemoteWebDriver

findElement

protected org.openqa.selenium.WebElement findElement(java.lang.String by,
                                                     java.lang.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

findElements

public java.util.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 java.util.List<org.openqa.selenium.WebElement> findElements(java.lang.String by,
                                                                      java.lang.String using)
Overrides:
findElements in class org.openqa.selenium.remote.RemoteWebDriver

findElements

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

getPageSource

public java.lang.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

getTitle

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

getWindowHandle

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

getWindowHandles

public java.util.Set<java.lang.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

listFrames

public java.util.List<java.lang.String> listFrames()
Returns:
list of frames

escapeJsString

protected java.lang.String escapeJsString(java.lang.String string)
Escape characters for safe insertion in a Javascript string contained by double quotes (").

Parameters:
string - the string to escape
Returns:
an escaped string

processElements

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

waitForLoadToComplete

public void waitForLoadToComplete()

findElementByName

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

findElementsByName

public java.util.List<org.openqa.selenium.WebElement> findElementsByName(java.lang.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 org.openqa.selenium.WebDriver.Options manage()
Specified by:
manage in interface org.openqa.selenium.WebDriver
Overrides:
manage in class org.openqa.selenium.remote.RemoteWebDriver

operaAction

public void operaAction(java.lang.String using,
                        java.lang.String... params)
Performs a special action, such as setting an Opera preference.

Parameters:
using - The action to perform. For a list of actions call getOperaActionList() at run time
params - Parameters to pass to the action call

saveScreenshot

public ScreenShotReply saveScreenshot(long timeout,
                                      java.lang.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

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

isOperaIdleAvailable

public boolean isOperaIdleAvailable()

setUseOperaIdle

public void setUseOperaIdle(boolean useIdle)

executeScript

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

isJavascriptEnabled

public boolean isJavascriptEnabled()
Is JavaScript enables in this driver?

Returns:
true if JavaScript is enabled

executeActions

@Deprecated
public void executeActions(OperaAction action)
Deprecated. 

Parameters:
action - a string identifying the Opera Action to use.

key

public void key(java.lang.String key)
Presses and releases the given key. If the key is "enter" then OperaDriver waits for the page to finish loading.

Parameters:
key - A string containing the key to press. This can be a single character (e.g. "a") or a special key (e.g. "left"), and is matched case insensitively. For a list of keys see OperaKeys.

keyDown

public void keyDown(java.lang.String key)
Presses and holds the given key. You cannot press a key that is already down.

Parameters:
key - the key to press, see key(String) for more information.

keyUp

public void keyUp(java.lang.String key)
Releases the given key.

Parameters:
key - the key to release, see key(String) for more information.

releaseKeys

public void releaseKeys()
Releases all the currently pressed keys.


type

public void type(java.lang.String using)
Types the given string as-is in to the browser window. To press special keys use key(String).

Parameters:
using - the string to type

getVersion

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

Returns:
version number

getScriptDebugger

protected IEcmaScriptDebugger getScriptDebugger()

getExecService

protected IOperaExec getExecService()

getWindowManager

protected IWindowManager getWindowManager()

getScopeServices

protected ScopeServices getScopeServices()

getPref

public java.lang.String getPref(java.lang.String section,
                                java.lang.String key)
Get the value of the requested preference.

Parameters:
section - the section the preference is in
key - the key name of the preference to get
Returns:
the value of the preference

getDefaultPref

public java.lang.String getDefaultPref(java.lang.String section,
                                       java.lang.String key)
Gets the default value of the requested preference.

Parameters:
section - the section the preference is in
key - the key name of the preference
Returns:
the default string value of the preference

listPrefs

public java.util.Map<java.lang.String,PrefsProtos.Pref> listPrefs(boolean sort,
                                                                  java.lang.String section)
Returns a Map of preference names to preferences in the requested section.

Parameters:
sort - whether to alphabetically sort the preference keys
section - the section to retrieve the preferences from
Returns:
a Map of preference names to preferences.

listAllPrefs

public java.util.Map<java.lang.String,java.util.Map<java.lang.String,PrefsProtos.Pref>> listAllPrefs()
Returns a Map of sections names mapping to a Map of preference names mapping to Pref objects.

Returns:
a map of preference objects

setPref

public void setPref(java.lang.String section,
                    java.lang.String key,
                    java.lang.String value)
Set the value of a preference using section and key as locators.

Parameters:
section - the section the preference is in
key - the key name of the preference to set
value - the value to set the preference to

executeAsyncScript

public java.lang.Object executeAsyncScript(java.lang.String script,
                                           java.lang.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

selftest

public java.lang.String selftest(java.util.List<java.lang.String> modules,
                                 long timeout)

utils

public Utils utils()

getOperaRunner

@Deprecated
public OperaRunner getOperaRunner()
Deprecated. 



Copyright © 2011. All Rights Reserved.