com.opera.core.systems
Class OperaSettings

java.lang.Object
  extended by com.opera.core.systems.OperaSettings

public class OperaSettings
extends Object

Manages settings specific to OperaDriver. OperaSettings serves as the internal storage for OperaDriver related settings and as a converter between DesiredCapabilities and other internal resources. Example usage:


   OperaSettings settings = new OperaSettings();
   settings.setBinary(new File("/path/to/opera"));
   settings.arguments().add("foo", "bar");
   settings.logging().getLevel(Level.FINE);
 
For use with OperaDriver:

   OperaDriver driver = new OperaDriver(settings);
 
For use with RemoteWebDriver:

   DesiredCapabilities capabilities = DesiredCapabilities.opera();
   capabilities.merge(settings.toCapabilities());
   RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),
                                                capabilities);
 

Since:
0.12
Author:
Andreas Tolf Tolfsen

Nested Class Summary
static class OperaSettings.Builder
          Supplier of an OperaSettings instance with the ability to specify which OperaSettings.Builder.usingProfile(OperaProfile) to use.
static class OperaSettings.Capability
          The capabilities specifically available to Opera.
 class OperaSettings.OperaLogging
          Manages settings related to logging in OperaDriver and related processes, such as OperaRunner and Opera itself.
 
Constructor Summary
OperaSettings()
          Constructs a new set of settings for OperaDriver and Opera to use.
OperaSettings(OperaProfile profile)
          Constructs a new set of settings for OperaDriver and Opera to use based on the given profile.
 
Method Summary
 OperaArguments arguments()
          Gets the arguments passed on to Opera.
 boolean autostart()
          Whether or not Opera should be launched on initialization.
 void autostart(boolean enabled)
          Enable or disable whether Opera should be launched on initialization.
 String getBackend()
          Deprecated.  
 File getBinary()
          Returns the browser binary executable.
 Integer getDisplay()
          Gets the X display used.
 String getHost()
          Returns the Scope server host the debugger should connect to.
 File getLauncher()
          Gets the launcher to use with OperaLauncherRunner, if any.
 int getPort()
          Gets the port the debugger should connect to.
 OperaProduct getProduct()
          Returns the product currently used, for example OperaProduct.DESKTOP or OperaProduct.CORE.
 boolean hasDetach()
          Whether to detach the Opera browser when the driver shuts down.
 OperaSettings.OperaLogging logging()
          Returns the OperaSettings.OperaLogging interface for managing logging levels and logging to file for OperaDriver.
 OperaSettings merge(org.openqa.selenium.Capabilities capabilities)
          Merge a set of capabilities in to these settings.
 boolean noRestart()
          Deprecated.  
 void noRestart(boolean enabled)
          Deprecated.  
 OperaProfile profile()
          Returns an OperaProfile object containing all settings related to the Opera profile to be used.
 void setBackend(String backend)
          Deprecated.  
 void setBinary(File binary)
          Sets Opera's binary executable location.
 void setDetach(boolean enabled)
          Specifies whether to detach the Opera browser when the driver shuts down.
 void setDisplay(int display)
          Sets the X display to use.
 void setHost(String ip)
          Specifies which Scope server the debugger should connect to.
 void setIdle(boolean enabled)
          Whether to use Opera's alternative implicit wait implementation.
 void setLauncher(File launcherBinary)
          Specifies launcher to use.
 void setPort(int port)
          Specifies the port the debugger should connect to.
 void setProduct(OperaProduct product)
          Sets the product currently used, for example desktop or core.
 void setProfile(OperaProfile profile)
          Sets the profile to use as an Opera profile represented as an object.
 void setProfile(String profileDirectory)
          Sets the directory to use for the Opera profile.
 boolean supportsDebugProxy()
          Whether or not the currently specified Opera configuration supports the -debugproxy command-line argument.
 boolean supportsPd()
          Whether or not the currently specified Opera configuration supports the -pd command-line argument.
 org.openqa.selenium.Capabilities toCapabilities()
          Returns this as capabilities.
 org.json.JSONObject toJson()
          Converts this instance to its JSON representation.
 String toString()
          String representation of the Opera specific settings.
 boolean useIdle()
          Whether to use Opera's alternative implicit wait implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OperaSettings

public OperaSettings()
Constructs a new set of settings for OperaDriver and Opera to use. The default settings are populated from OperaSettings.Capability.


OperaSettings

public OperaSettings(OperaProfile profile)
Constructs a new set of settings for OperaDriver and Opera to use based on the given profile.

Parameters:
profile - the profile to use
Method Detail

logging

public OperaSettings.OperaLogging logging()
Returns the OperaSettings.OperaLogging interface for managing logging levels and logging to file for OperaDriver.

Returns:
relevant methods for getting and setting logging settings

getBinary

public File getBinary()
Returns the browser binary executable.

Returns:
the Opera binary

setBinary

public void setBinary(File binary)
Sets Opera's binary executable location.

Parameters:
binary - the Opera binary

arguments

public OperaArguments arguments()
Gets the arguments passed on to Opera.

Returns:
arguments passed on to Opera

getHost

public String getHost()
Returns the Scope server host the debugger should connect to.

Returns:
the host

setHost

public void setHost(String ip)
Specifies which Scope server the debugger should connect to.

Parameters:
ip - IP address (hostnames are not allowed) to the Scope server

getPort

public int getPort()
Gets the port the debugger should connect to.

Returns:
local port number for the debugger to connect to

setPort

public void setPort(int port)
Specifies the port the debugger should connect to.

Parameters:
port - local port number for the debugger to connect to

getLauncher

public File getLauncher()
Gets the launcher to use with OperaLauncherRunner, if any. If autostart() is false the launcher will not be used. If not set, this method will return the default location of the launcher on your system.

Returns:
location of launcher

setLauncher

public void setLauncher(File launcherBinary)
                 throws IOException
Specifies launcher to use. If autostart() is false, it will not be used.

Parameters:
launcherBinary - the launcher binary
Throws:
IOException - if there is a problem with the provided launcher

profile

public OperaProfile profile()
Returns an OperaProfile object containing all settings related to the Opera profile to be used. This might be anything from the path to the profile directory, to preferences used in Opera.

Returns:
the Opera profile

setProfile

public void setProfile(String profileDirectory)
Sets the directory to use for the Opera profile. If null, generate a temporary directory. If not empty use the given directory. To not create a temporary directory for backwards compatibility reasons, set it to an empty string (""), such as for Opera < 11.60.

Parameters:
profileDirectory - the path to the profile directory

setProfile

public void setProfile(OperaProfile profile)
Sets the profile to use as an Opera profile represented as an object.

Parameters:
profile - the Opera profile to use

useIdle

public boolean useIdle()
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.

Returns:
whether or not idle is in use

setIdle

public void setIdle(boolean enabled)
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. Idle can be switch on or off during runtime.

Parameters:
enabled - to enable or disable idle

getDisplay

public Integer getDisplay()
Gets the X display used. Only works on GNU/Linux.

Returns:
the X display

setDisplay

public void setDisplay(int display)
Sets the X display to use. Only works on GNU/Linux. Typically this allows you to open Opera in an X virtual framebuffer.

Parameters:
display - the X display to use
Throws:
UnsupportedOperationException - if on a non-GNU/Linux operating system

autostart

public boolean autostart()
Whether or not Opera should be launched on initialization. If disabled, OperaDriver will wait and listen for an incoming Scope client connection.

Returns:
true if Opera is to be started automatically, false otherwise

autostart

public void autostart(boolean enabled)
Enable or disable whether Opera should be launched on initialization. If disabled, OperaDriver will wait and listen for incoming an incoming Scope client connection. This cannot be set during runtime. This is true by default.

Parameters:
enabled - true if Opera should be started automatically, false otherwise

getProduct

public OperaProduct getProduct()
Returns the product currently used, for example OperaProduct.DESKTOP or OperaProduct.CORE.

Returns:
the profile configuration set

setProduct

public void setProduct(OperaProduct product)
Sets the product currently used, for example desktop or core.

Parameters:
product - the profile configuration to use

noRestart

@Deprecated
public boolean noRestart()
Deprecated. 

Whether to restart or not. Only used in OperaDesktopDriver. It is false by default.

Returns:
true if Opera should restart, false otherwise

noRestart

@Deprecated
public void noRestart(boolean enabled)
Deprecated. 

Whether to restart or not. Only affects OperaDesktopDriver.

Parameters:
enabled - true if Opera should be restart, false otherwise

hasDetach

public boolean hasDetach()
Whether to detach the Opera browser when the driver shuts down. If true, this will leave Opera running.

Returns:
true if Opera should keep running, false if Opera should be shut down

setDetach

public void setDetach(boolean enabled)
Specifies whether to detach the Opera browser when the driver shuts down. If true, this will leave Opera running.

Parameters:
enabled - true will leave Opera running, false will shut down Opera along with driver

getBackend

@Deprecated
public String getBackend()
Deprecated. 

Gets rendering backend used. If null or an empty string, "software" is used by default. This will only be used if using OperaLauncherRunner (i.e. if autostart() and getLauncher() are specified). Warning: This is a temporary workaround for launcher not taking external window-only screenshots on Windows.

Returns:
the backend to use for gogi

setBackend

@Deprecated
public void setBackend(String backend)
Deprecated. 

Specifies the rendering backend used by internal gogi builds of Opera. If null or an empty string, "software" is used by default. This will only be used if using OperaLauncherRunner (i.e. if autostart() and getLauncher() are specified). Warning: This is a temporary workaround for launcher not taking external window-only screenshots on Windows.

Parameters:
backend - the backend to use for gogi, either "software" or "hardware"

supportsDebugProxy

public boolean supportsDebugProxy()
Whether or not the currently specified Opera configuration supports the -debugproxy command-line argument. If the specified port is not equal to the default proxy server port specified in OperaIntervals.SERVER_DEFAULT_PORT, this will be true.

Returns:
true if this configuration supports the -debugproxy command-line argument, false otherwise

supportsPd

public boolean supportsPd()
Whether or not the currently specified Opera configuration supports the -pd command-line argument. PD stands for personal directory, and refers to a profile for Opera.

Returns:
true if this configuration supports the -pd command-line argument.

merge

public OperaSettings merge(org.openqa.selenium.Capabilities capabilities)
Merge a set of capabilities in to these settings. The settings corresponding to the opera. capability prefix will be updated, while surplus/unknown capabilities will be stored. They can later be retrieved using the toCapabilities() method on this object.

Parameters:
capabilities - capabilities to merge into these settings
Returns:
reference to self

toCapabilities

public org.openqa.selenium.Capabilities toCapabilities()
Returns this as capabilities. This does not copy the settings. Further changes will be reflected in the capabilities.

Returns:
Capabilities for Opera with these settings

toJson

public org.json.JSONObject toJson()
                           throws IOException,
                                  org.json.JSONException
Converts this instance to its JSON representation.

Returns:
the JSON representation of these settings
Throws:
IOException - if an I/O error occurs
org.json.JSONException - if an error occurs while encoding these settings as JSON

toString

public String toString()
String representation of the Opera specific settings.

Overrides:
toString in class Object
Returns:
string representation of this


Copyright © 2012. All Rights Reserved.