public class RemoteDriver
extends org.openqa.selenium.remote.RemoteWebDriver
implements org.openqa.selenium.TakesScreenshot
Modifier and Type | Class and Description |
---|---|
static class |
RemoteDriver.SessionInfo
The current format of each SessionInfo when stored in file:
|
org.openqa.selenium.remote.RemoteWebDriver.RemoteTargetLocator, org.openqa.selenium.remote.RemoteWebDriver.RemoteWebDriverOptions, org.openqa.selenium.remote.RemoteWebDriver.When
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
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CAPABILITY_ID
"ID"
|
static java.lang.String |
CAPABILITY_RECONNECT
"RECONNECT"
|
static java.lang.String |
CAPABILITY_REMOTESERVER
"REMOTESERVER"
|
static java.lang.String |
debugLogFile
The debug log file containing debug message when calling main() to start "selenium server".
|
static java.lang.String |
DEFAULT_CONNECTION_TEST_COMMAND
"getAlertText" defines the default selenium-driver-command
used to test the connection between WebDriver and BrowserDriver.
|
protected boolean |
isGrid
if this is a grid-hub server
|
static java.lang.String |
JAVA_TMPDIR
"java.io.tmpdir"
|
static java.lang.String |
LAST_SESSION_KEY
"LASTSESSION"
|
java.lang.String |
remote_hostname
parsed hostname of the remote selenium server (standalone or grid-hub)
might be needed for additional Selenium RMI Server communication.
|
int |
remote_port
parsed port number of the remote selenium server (standalone or grid-hub)
might be needed for get grid-node information.
|
java.net.URL |
remote_URL
The URL provided at construction time.
|
java.lang.String |
rmi_hostname
hostname of the remote grid-node.
|
int |
rmi_registry_port |
SeleniumAgent |
rmiAgent
A SeleniumRMIAgent, if enabled, to communicate with a remote SAFS Selenium RMI Server.
This may be null if we could not initialize an agent or find a server. This may also be non-null, but not connected to an RMI server if the server is not running. |
static java.lang.String |
SESSION_FILE
"selenium.session.tmp"
|
Constructor and Description |
---|
RemoteDriver(org.openqa.selenium.remote.DesiredCapabilities capabilities)
Not used by SAFS Selenium.
Should not be used if retaining SAFS Selenium RMI Server capabilities. |
RemoteDriver(java.net.URL selenium_server_url,
org.openqa.selenium.remote.DesiredCapabilities capabilities)
Connect to a remote selenium standalone server.
We will also parse the URL to attempt to connect to a SAFS Selenium RMI Server on RMI-SERVER-HOST. The RMI-SERVER-HOST can be: 1. |
Modifier and Type | Method and Description |
---|---|
static void |
deleteSessionFile() |
static void |
deleteSessionIdFromFile(java.lang.String Id)
Delete the session from the RemoteDriver file with the given Id.
|
protected org.openqa.selenium.remote.Response |
execute(java.lang.String driverCommand,
java.util.Map<java.lang.String,?> parameters) |
java.lang.Object |
executeScript(java.lang.String script,
java.lang.Object... args) |
java.lang.String |
getBrowserName() |
java.lang.String |
getBrowserVersion() |
java.lang.String |
getDriverVersion() |
long |
getExecutionTime(java.lang.String command,
int timeoutWaitForComponent) |
java.lang.String |
getPlatform() |
<X> X |
getScreenshotAs(org.openqa.selenium.OutputType<X> target) |
static java.util.List<RemoteDriver.SessionInfo> |
getSessionsFromFile()
Returns a List of SessionInfo objects.
|
boolean |
hasQuit() |
boolean |
isConnectionFine(java.lang.String command,
long maxDuration,
int timeoutWaitForComponent)
Test if the connection between WebDriver and the browser-driver is good enough to satisfy user's need.
|
boolean |
isLocalServer() |
static boolean |
isNewSession() |
static void |
main(java.lang.String[] args)
This main method will start a Selenium Server (standalone, hub, or node).
|
protected void |
parseSeleniumServerURL(java.net.URL url)
Extract the needed remote_hostname and remote_port from the selenium server URL.
|
void |
quit() |
static RemoteDriver.SessionInfo |
retrieveSessionInfoFromFile(java.lang.String Id)
Retrieve the remote server's session information for the session with the given id.
|
static RemoteDriver.SessionInfo |
retriveLastSessionInfoFromFile()
Retrieve SessionInfo representing the "current" or "last" session
|
static java.lang.String |
retriveSessionIdFromFile(java.lang.String Id)
Retrieve the remote server's session string for the session with the given id.
|
static void |
setLastSessionId(java.lang.String Id) |
protected void |
startRMIAgent(java.lang.String rmihost,
int rmiport)
try to start a SAFS Selenium RMI Agent if our "selenium server" is NOT on localhost or it is a "grid hub server".
|
void |
startSession(org.openqa.selenium.Capabilities desiredCapabilities,
org.openqa.selenium.Capabilities requiredCapabilities)
Called internally by OpenQA RemoteWebDriver during Constructor initialization.
|
static void |
storeSessionIdToFile(java.lang.String serverHostname,
java.lang.String Id,
java.lang.String browserName,
java.lang.String sessionid,
org.openqa.selenium.Capabilities desiredCapabilities) |
close, execute, executeAsyncScript, findElement, findElement, findElementByClassName, findElementByCssSelector, findElementById, findElementByLinkText, findElementByName, findElementByPartialLinkText, findElementByTagName, findElementByXPath, findElements, findElements, findElementsByClassName, findElementsByCssSelector, findElementsById, findElementsByLinkText, findElementsByName, findElementsByPartialLinkText, findElementsByTagName, findElementsByXPath, get, getCapabilities, getCommandExecutor, getCurrentUrl, getElementConverter, getErrorHandler, getExecuteMethod, getFileDetector, getKeyboard, getMouse, getPageSource, getSessionId, getTitle, getW3CStandardComplianceLevel, getWindowHandle, getWindowHandles, log, manage, navigate, setCommandExecutor, setElementConverter, setErrorHandler, setFileDetector, setFoundBy, setLogLevel, setSessionId, startClient, startSession, stopClient, switchTo, toString
public java.net.URL remote_URL
public java.lang.String remote_hostname
public int remote_port
public java.lang.String rmi_hostname
public int rmi_registry_port
public SeleniumAgent rmiAgent
public static final java.lang.String LAST_SESSION_KEY
public static final java.lang.String JAVA_TMPDIR
public static final java.lang.String SESSION_FILE
public static final java.lang.String CAPABILITY_ID
public static final java.lang.String CAPABILITY_RECONNECT
public static final java.lang.String CAPABILITY_REMOTESERVER
protected boolean isGrid
public static final java.lang.String DEFAULT_CONNECTION_TEST_COMMAND
public static final java.lang.String debugLogFile
public RemoteDriver(org.openqa.selenium.remote.DesiredCapabilities capabilities)
capabilities
- RemoteDriver(URL, DesiredCapabilities)
public RemoteDriver(java.net.URL selenium_server_url, org.openqa.selenium.remote.DesiredCapabilities capabilities)
selenium_server_url
- -- URL of the remote Selenium Server.
capabilities
- -- to enable the possibility of SAFS Selenium RMI Server/Agent communication
you must set a "capability" of REMOTESERVER to be the hostname of the remote selenium server.
Ex: capabilities.setCapability(RemoteDriver.CAPABILITY_REMOTESERVER, hostname);
This is done automatically within the SAFS Selenium code where needed. Only advanced users doing custom initialization and instantiation need set this capability.
public java.lang.String getBrowserName()
public java.lang.String getBrowserVersion()
public java.lang.String getPlatform()
public java.lang.String getDriverVersion()
protected void startRMIAgent(java.lang.String rmihost, int rmiport)
rmihost
- String, the host name of the RMI serverrmiport
- int, the port number of the RMI server, default is 1099public boolean isLocalServer()
protected void parseSeleniumServerURL(java.net.URL url)
URL
- - URL of the Selenium Server used.public void quit()
quit
in interface org.openqa.selenium.WebDriver
quit
in class org.openqa.selenium.remote.RemoteWebDriver
public boolean hasQuit()
public void startSession(org.openqa.selenium.Capabilities desiredCapabilities, org.openqa.selenium.Capabilities requiredCapabilities)
startSession
in class org.openqa.selenium.remote.RemoteWebDriver
public boolean isConnectionFine(java.lang.String command, long maxDuration, int timeoutWaitForComponent) throws SeleniumPlusException
command
- String, the selenium driver command to use to test execution timemaxDuration
- long, the maximum execution duration that user can accepttimeoutWaitForComponent
- int, the original timeout to wait for a GUI componentSeleniumPlusException
- if the parameter command is null or emptypublic long getExecutionTime(java.lang.String command, int timeoutWaitForComponent) throws SeleniumPlusException
command
- String, the selenium driver command to use to test execution timetimeoutWaitForComponent
- int, the original timeout to wait for a GUI componentSeleniumPlusException
- if the parameter command is null or emptyprotected org.openqa.selenium.remote.Response execute(java.lang.String driverCommand, java.util.Map<java.lang.String,?> parameters)
execute
in class org.openqa.selenium.remote.RemoteWebDriver
public static boolean isNewSession()
public static void storeSessionIdToFile(java.lang.String serverHostname, java.lang.String Id, java.lang.String browserName, java.lang.String sessionid, org.openqa.selenium.Capabilities desiredCapabilities) throws java.lang.Exception
java.lang.Exception
public static void deleteSessionIdFromFile(java.lang.String Id) throws java.lang.Exception
Id
- java.lang.Exception
- if there is a problem reading or deleting the session info.public static RemoteDriver.SessionInfo retrieveSessionInfoFromFile(java.lang.String Id) throws java.lang.Exception
Id
- java.lang.Exception
public static java.lang.String retriveSessionIdFromFile(java.lang.String Id) throws java.lang.Exception
Id
- java.lang.Exception
public static void setLastSessionId(java.lang.String Id) throws java.lang.Exception
java.lang.Exception
public static RemoteDriver.SessionInfo retriveLastSessionInfoFromFile() throws java.lang.Exception
java.lang.Exception
public static java.util.List<RemoteDriver.SessionInfo> getSessionsFromFile() throws java.lang.Exception
java.lang.Exception
- if the sessions are not retrievable (do not exist).public static void deleteSessionFile()
public <X> X getScreenshotAs(org.openqa.selenium.OutputType<X> target) throws org.openqa.selenium.WebDriverException
getScreenshotAs
in interface org.openqa.selenium.TakesScreenshot
getScreenshotAs
in class org.openqa.selenium.remote.RemoteWebDriver
org.openqa.selenium.WebDriverException
public java.lang.Object executeScript(java.lang.String script, java.lang.Object... args)
executeScript
in interface org.openqa.selenium.JavascriptExecutor
executeScript
in class org.openqa.selenium.remote.RemoteWebDriver
public static void main(java.lang.String[] args)
args
- String[], it accepts following arguments:DriverConstant.SeleniumConfigConstant.SELENIUMSERVER_JVM_OPTIONS
DriverConstant.SeleniumConfigConstant.SELENIUMSERVER_JVM_Xms
DriverConstant.SeleniumConfigConstant.SELENIUMSERVER_JVM_Xmx
DriverConstant.PROPERTY_SAFS_PROJECT_ROOT
Copyright © SAS Institute. All Rights Reserved.