public class SeleniumAgent extends RemoteRoot implements SeleniumRMIAgent
Because this is an RMI implementation, an additional Java rmic build process is necessary prior to creating the JAR file containing all classes. The Java rmic program creates the Skeletons and Stubs needed by Java RMI.
Execute Java rmic from the root directory of the Java project:
rmic -d . org.safs.selenium.rmi.agent.SeleniumAgent
Note: For consistent operation the safs.server.hostname
needs to be set in code or
on the command line before launching an Agent connecting to a remote Selenium RMI Server:
System.setProperty("safs.server.hostname", "<rmi server ip>");
System.setProperty("safs.server.hostname", "hostname.company.internal.net");
-Dsafs.server.hostname=<rmi server ip>
-Dsafs.server.hostname=hostname.company.internal.net
SeleniumServerRunner
,
SeleniumRMIServer
,
SeleniumServer
,
Serialized FormModifier and Type | Class and Description |
---|---|
protected class |
SeleniumAgent.ServerMonitor
Polls the server host for a Java Registry every few seconds until one with the proper
server object is found.
|
RemoteRoot.ShutdownHook
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_COMMAND_SEPARATOR |
protected boolean |
hostOverride
If the user sets the serverHost then we won't look for System Properties.
|
protected SeleniumAgent.ServerMonitor |
monitor |
protected java.rmi.server.ObjID |
objID |
SeleniumRMIServer |
server
The remote SAFS RMI SeleniumServer reference.
|
protected java.lang.String |
serverHost
Each Agent may have a different RMI Server (Mac, Unix, Windows, Android, etc..)
This setting "overrides/hides" the static serverHost of the RemoteRoot superclass.
|
protected java.lang.String |
serverName
Subclasses will override to seek out different RMI Server Objects.
|
protected boolean |
shutdown |
DEFAULT_RMI_SERVER_HOST, remoteType
DEFAULT_RMI_AGENT, SERVER_HOSTNAME_SYSTEM_PROPERTY
Constructor and Description |
---|
SeleniumAgent() |
Modifier and Type | Method and Description |
---|---|
void |
clearClipboard()
Clear the clipboard on the machine where the RMI server is running.
|
void |
disconnect()
Used locally to cease all agent operations with any server and commence a complete RMI
disconnect.
|
java.rmi.server.ObjID |
getAgentID()
Called by an RMI Server.
|
java.lang.String |
getAgentName()
Called by an RMI Server.
|
java.lang.Object |
getClipboard(java.awt.datatransfer.DataFlavor dataFlavor)
Get content of the clipboard on the machine where the RMI server is running.
|
void |
initialize()
MUST be called by instances after object construction.
If dynamically setting the desire selenium server host you must set that prior to initialization. |
static void |
main(java.lang.String[] args)
For test purposes only.
|
void |
ping()
Does nothing but verify the integrity of the RMI connection and log entry.
|
void |
remoteClick(int screen_x,
int screen_y,
int mouseButtonNumber,
int nclicks) |
void |
remoteClickWithKeyPress(int screen_x,
int screen_y,
int mouseButtonNumber,
int keyCode,
int nclicks) |
void |
remoteKeyPress(int keycode) |
void |
remoteKeyRelease(int keycode) |
void |
remoteMouseWheel(int wheelAmt) |
void |
remoteSetKeyDelay(int millisDelay) |
void |
remoteTypeChars(java.lang.String keys) |
void |
remoteTypeKeys(java.lang.String keys) |
void |
remoteWaitReaction(boolean wait)
Set if wait for reaction to "input keys/chars" for remote server.
|
void |
remoteWaitReaction(boolean wait,
int tokenLength,
int dealyForToken,
int dealy)
Set if wait for reaction to "input keys/chars" for remote server.
|
java.lang.Object |
runCommand(java.lang.Object command)
Called by an RMI Server.
|
void |
setClipboard(java.lang.String content)
Set content to the clipboard on the machine where the RMI server is running.
|
void |
setSeparator(java.lang.String separator)
Set the separator to separate command and parameters.
|
void |
setServerHost(java.lang.String hostname)
Provide a runtime override of the target selenium server hostname.
This overrides System Properties settings for 'safs.server.hostname'. MUST be called before initialize(). |
void |
shutdown()
Called from the remote RMI Server.
|
finalize, rebindLocalRMIRegistry
clone, exportObject, exportObject, exportObject, unexportObject
public static final java.lang.String DEFAULT_COMMAND_SEPARATOR
public SeleniumRMIServer server
protected boolean shutdown
protected SeleniumAgent.ServerMonitor monitor
protected java.rmi.server.ObjID objID
protected boolean hostOverride
setServerHost(String)
protected java.lang.String serverName
protected java.lang.String serverHost
public SeleniumAgent() throws java.rmi.RemoteException
java.rmi.RemoteException
public void setServerHost(java.lang.String hostname)
hostname
- RemoteRoot.serverHost
public void initialize()
setServerHost(String)
public void ping() throws java.rmi.RemoteException
ping
in interface SeleniumRMIAgent
java.rmi.RemoteException
Agent.ping()
public java.rmi.server.ObjID getAgentID() throws java.rmi.RemoteException
SeleniumRMIAgent
getAgentID
in interface SeleniumRMIAgent
java.rmi.RemoteException
Agent.getAgentID()
public java.lang.String getAgentName() throws java.rmi.RemoteException
SeleniumRMIAgent
getAgentName
in interface SeleniumRMIAgent
java.rmi.RemoteException
Agent.getAgentName()
public void disconnect()
public void shutdown() throws java.rmi.RemoteException
shutdown
in interface SeleniumRMIAgent
java.rmi.RemoteException
Agent.shutdown()
public java.lang.Object runCommand(java.lang.Object command) throws java.rmi.RemoteException, java.lang.Exception
SeleniumRMIAgent
For example, the Client and Server may have been coded to pass string commands back and forth and the string commands can be parsed to provide an unlimited number of command possibilities.
runCommand
in interface SeleniumRMIAgent
command
- Object of a type expected by the Client implementation for this method.java.rmi.RemoteException
java.lang.Exception
public void setSeparator(java.lang.String separator)
separator
- public void remoteClick(int screen_x, int screen_y, int mouseButtonNumber, int nclicks) throws java.rmi.ServerException, java.lang.Exception
screen_x
- screen_y
- mouseButtonNumber
- nclicks
- java.rmi.ServerException
- if the command did not execute successfullyjava.lang.Exception
public void remoteClickWithKeyPress(int screen_x, int screen_y, int mouseButtonNumber, int keyCode, int nclicks) throws java.rmi.ServerException, java.lang.Exception
screen_x
- screen_y
- mouseButtonNumber
- keyCode
- nclicks
- java.rmi.ServerException
- if the command did not execute successfullyjava.lang.Exception
public void remoteKeyPress(int keycode) throws java.rmi.ServerException, java.lang.Exception
keycode
- int, the key to pressjava.rmi.ServerException
- if the command did not execute successfullyjava.lang.Exception
public void remoteKeyRelease(int keycode) throws java.rmi.ServerException, java.lang.Exception
keycode
- int, the key to releasejava.rmi.ServerException
- if the command did not execute successfullyjava.lang.Exception
public void remoteMouseWheel(int wheelAmt) throws java.rmi.ServerException, java.lang.Exception
wheelAmt
- int, the mouse wheel to scrolljava.rmi.ServerException
- if the command did not execute successfullyjava.lang.Exception
public void remoteTypeKeys(java.lang.String keys) throws java.rmi.ServerException, java.lang.Exception
keys
- java.rmi.ServerException
- if the command did not execute successfullyjava.lang.Exception
public void remoteSetKeyDelay(int millisDelay) throws java.rmi.ServerException, java.lang.Exception
millisDelay
- between keystrokesjava.rmi.ServerException
- if the command did not execute successfullyjava.lang.Exception
public void remoteWaitReaction(boolean wait) throws java.rmi.ServerException, java.lang.Exception
wait
- boolean if wait or not.java.rmi.ServerException
- if the command did not execute successfullyjava.lang.Exception
Robot.setWaitReaction(boolean)
public void remoteWaitReaction(boolean wait, int tokenLength, int dealyForToken, int dealy) throws java.rmi.ServerException, java.lang.Exception
wait
- boolean, if wait or not.tokenLength
- int, the length of a token. Only if the string is longer than this
then we wait the reaction after input-keys a certain time
indicated by the parameter dealyForToken.dealyForToken
- int, The delay in millisecond to wait the reaction after input-keys
for the string as long as a token.dealy
- int, The constant delay in millisecond to wait the reaction after input-keys.java.rmi.ServerException
- if the command did not execute successfullyjava.lang.Exception
Robot.setWaitReaction(boolean, int, int, int)
public void remoteTypeChars(java.lang.String keys) throws java.rmi.ServerException, java.lang.Exception
String
- charjava.rmi.ServerException
- if the command did not execute successfullyjava.lang.Exception
public void clearClipboard() throws java.rmi.ServerException, java.lang.Exception
java.rmi.ServerException
- if the command did not execute successfullyjava.lang.Exception
- for other problemspublic void setClipboard(java.lang.String content) throws java.rmi.ServerException, java.lang.Exception
content
- String, the string content to set to clipboardjava.rmi.ServerException
- if the command did not execute successfullyjava.lang.Exception
- for other problemspublic java.lang.Object getClipboard(java.awt.datatransfer.DataFlavor dataFlavor) throws java.rmi.ServerException, java.lang.Exception
dataFlavor
- DataFlavor, the data flavor for the content in clipboardjava.rmi.ServerException
- if the command did not execute successfullyjava.lang.Exception
- for other problemspublic static void main(java.lang.String[] args) throws java.rmi.RemoteException
args
- String[]
java.rmi.RemoteException
Copyright © SAS Institute. All Rights Reserved.