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:
MockOperaDriver, OperaDesktopDriver, TestOperaDriver

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
           
static class OperaDriver.OperaTimeouts
           
 class OperaDriver.OperaUtils
          Interface for accessing the browser's meta- and utility information.
static class OperaDriver.PrivateData
          Different types of data stored by Opera.
 
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  Set<Integer> objectIds
           
protected  OperaRunner runner
           
protected  OperaSettings settings
           
 
Constructor Summary
OperaDriver()
          Constructor that starts Opera with the default set of capabilities.
OperaDriver(org.openqa.selenium.Capabilities capabilities)
          Starts Opera with the given set of desired capabilities.
OperaDriver(OperaProfile profile)
          Starts Opera with the given profile.
OperaDriver(OperaSettings s)
          Starts Opera with the given settings.
 
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  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.
protected  ScopeServices getScopeServices()
           
<X> X
getScreenshotAs(org.openqa.selenium.OutputType<X> target)
           
protected  IEcmaScriptDebugger getScriptDebugger()
           
protected  Map<String,String> getServicesList()
           
 String getTitle()
           
 int getWindowCount()
           
 String getWindowHandle()
           
 Set<String> getWindowHandles()
           
protected
<X> X
implicitlyWaitFor(Callable<X> condition)
          Implicitly wait for an element to become visible.
protected  void init()
          Initialize required Scope services.
 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.
protected  void setUseOperaIdle(boolean enabled)
          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, setFoundBy, setLogLevel, setSessionId, startClient, startSession, stopClient, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

settings

protected final OperaSettings settings

runner

protected OperaRunner runner

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 capabilities)
Starts Opera with the given set of desired capabilities.

Parameters:
capabilities - a DesiredCapabilities object containing various settings for the driver and the browser

OperaDriver

public OperaDriver(OperaSettings s)
Starts Opera with the given settings.

Parameters:
s - Opera specific settings
Method Detail

init

protected void init()
Initialize required Scope services.


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

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

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. 

Gets list of available Opera actions.

Returns:
list of available actions

getScriptDebugger

protected IEcmaScriptDebugger getScriptDebugger()

getExecService

protected IOperaExec getExecService()

getScopeServices

protected ScopeServices getScopeServices()

processElements

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

waitForLoadToComplete

protected void waitForLoadToComplete()
                              throws ResponseNotReceivedException
Throws:
ResponseNotReceivedException

implicitlyWaitFor

protected <X> X implicitlyWaitFor(Callable<X> condition)
Implicitly wait for an element to become visible. Essentially it polls the client every OperaIntervals.POLL_INTERVAL until OperaIntervals.IMPLICIT_WAIT is reached for callable condition to be true.

Type Parameters:
X - computes a result, or throws an exception if unable to do so
Parameters:
condition - a callable implementation
Returns:
a non-null value if condition is met within implicit wait timeout, null otherwise

setUseOperaIdle

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

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


Copyright © 2012. All Rights Reserved.