public class SeleniumServer extends RemoteRoot implements SeleniumRMIServer
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.server.SeleniumServer
Note: For consistent operation the property java.rmi.server.hostname
needs to be set in code or
on the command line before launching an RMI Server:
System.setProperty("java.rmi.server.hostname", "<rmi server ip>");
System.setProperty("java.rmi.server.hostname", "hostname.company.internal.net");
-Djava.rmi.server.hostname=<rmi server ip>
-Djava.rmi.server.hostname=hostname.company.internal.net
Note: Normally Java exports a new RMI Object object using an anonymous port. If you want an explicit port,
please set property server.port
in code or on the command line:
-Dserver.port=<RMI server port>
System.setProperty("server.port", "8900");
Note: Normally Java creates a registry Object object using a konwn port 1099
.
If you want an other port for the registry, please set property registry.port
in code
or on the command line:
-Dregistry.port=<Remote Registry port>
System.setProperty("registry.port", "1100");
SeleniumServerRunner
,
SeleniumRMIAgent
,
SeleniumAgent
,
Serialized FormRemoteRoot.ShutdownHook
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CMD_CLICK |
static java.lang.String |
CMD_CLICK_WITH_KEY |
static java.lang.String |
CMD_CLIPBOARD_CLEAR |
static java.lang.String |
CMD_CLIPBOARD_GET |
static java.lang.String |
CMD_CLIPBOARD_SET |
static java.lang.String |
CMD_KEYPRESS |
static java.lang.String |
CMD_KEYRELEASE |
static java.lang.String |
CMD_MOUSEWHEEL |
static java.lang.String |
CMD_SET_KEY_DELAY |
static java.lang.String |
CMD_SET_WAIT_REACTION |
static java.lang.String |
CMD_TYPECHARS |
static java.lang.String |
CMD_TYPEKEYS |
protected java.lang.String |
serverName
Name of Server object in rmi Naming registry.
|
DEFAULT_RMI_SERVER_HOST, PROPERTY_REGISTRY_PORT, PROPERTY_SERVER_PORT, registryPort, remoteType, serverHost
DEFAULT_RMI_SERVER, JAVA_RMI_SERVER_HOSTNAME_PROPERTY, SERVER_SYSTEM_PROPERTY
Constructor and Description |
---|
SeleniumServer() |
SeleniumServer(int serverPort) |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Boolean |
clearClipboard()
Clear the clipboard.
|
protected java.lang.Object |
click(java.lang.String[] params)
Robot.click(x, y, mouseButton, nclicks);
|
protected java.lang.Object |
clickWithKeyPress(java.lang.String[] params)
Robot.clickWithKeyPress(x, y, mouseButton, keyCode, nclicks);
|
java.lang.Object |
execute(java.lang.Object command,
java.lang.Object... parameters)
Called by an RMI Agent.
|
protected java.lang.Object |
getClipboard(java.lang.Object... params)
Get clipboard's content.
|
void |
init() |
protected java.lang.Object |
keyPress(java.lang.String[] params)
Robot.keyPress(keyCode);
|
protected java.lang.Object |
keyRelease(java.lang.String[] params)
Robot.keyRelease(keyCode);
|
static void |
main(java.lang.String[] args)
Note: For consistent operation the property
java.rmi.server.hostname needs to be set in code or
on the command line before launching an RMI Server: |
protected java.lang.Object |
mouseWheel(java.lang.String[] params)
Robot.mouseWheel(keyCode);
|
protected void |
pingAgents()
Simple routine to ping each registered agent to see if it is actually still there.
|
void |
register(SeleniumRMIAgent anAgent)
Called by an RMI Agent.
|
java.lang.Object |
runCommand(java.lang.Object commandAndParameters)
Called by an RMI Agent.
|
protected java.lang.Boolean |
setClipboard(java.lang.Object... params)
Set string content to clipboard.
|
protected java.lang.Object |
setMillisBetweenKeystrokes(java.lang.String[] params)
Robot.setMillisBetweenKeystrokes(string);
|
protected java.lang.Object |
setWaitReaction(java.lang.String[] params)
|
protected java.lang.Object |
typeChars(java.lang.String[] params)
Robot.inputChars(string);
|
protected java.lang.Object |
typeKeys(java.lang.String[] params)
Robot.inputKeys(string);
|
void |
unRegister(SeleniumRMIAgent anAgent)
Called by an RMI Agent.
|
finalize, rebindLocalRMIRegistry
clone, exportObject, exportObject, exportObject, unexportObject
public static final java.lang.String CMD_CLICK
public static final java.lang.String CMD_CLICK_WITH_KEY
public static final java.lang.String CMD_KEYPRESS
public static final java.lang.String CMD_KEYRELEASE
public static final java.lang.String CMD_MOUSEWHEEL
public static final java.lang.String CMD_TYPEKEYS
public static final java.lang.String CMD_TYPECHARS
public static final java.lang.String CMD_SET_KEY_DELAY
public static final java.lang.String CMD_SET_WAIT_REACTION
public static final java.lang.String CMD_CLIPBOARD_CLEAR
public static final java.lang.String CMD_CLIPBOARD_SET
public static final java.lang.String CMD_CLIPBOARD_GET
protected java.lang.String serverName
public SeleniumServer() throws java.rmi.RemoteException
java.rmi.RemoteException
public SeleniumServer(int serverPort) throws java.rmi.RemoteException
serverPort
- java.rmi.RemoteException
public void init()
init
in class RemoteRoot
public void register(SeleniumRMIAgent anAgent) throws java.rmi.RemoteException
SeleniumRMIServer
register
in interface SeleniumRMIServer
java.rmi.RemoteException
public void unRegister(SeleniumRMIAgent anAgent) throws java.rmi.RemoteException
SeleniumRMIServer
unRegister
in interface SeleniumRMIServer
java.rmi.RemoteException
protected void pingAgents()
protected java.lang.Object click(java.lang.String[] params) throws java.rmi.ServerException
params
- String[]
field[0] int x (default 0) field[1] int y (default 0) field[2] int mouseButton (default MOUSE_BUTTON_LEFT) field[3] int numClicks (default 1)
java.rmi.ServerException
Robot.click(int, int, int, int)
protected java.lang.Object clickWithKeyPress(java.lang.String[] params) throws java.rmi.ServerException
params
- String[]
field[0] int x (default 0) field[1] int y (default 0) field[2] int mouseButton (default MOUSE_BUTTON_LEFT ) field[3] int keyCode (default int 0 -- unknown) field[4] int numClicks (default 1)
java.rmi.ServerException
Robot.clickWithKeyPress(int, int, int, int, int)
protected java.lang.Object keyPress(java.lang.String[] params) throws java.rmi.ServerException
params
- String[]
field[0] int keyCode
java.rmi.ServerException
- if failRobot.keyPress(int)
protected java.lang.Object keyRelease(java.lang.String[] params) throws java.rmi.ServerException
params
- String[]
field[0] int keyCode
java.rmi.ServerException
- if failRobot.keyRelease(int)
protected java.lang.Object mouseWheel(java.lang.String[] params) throws java.rmi.ServerException
params
- String[]
field[0] int, the wheel amount to scroll.
java.rmi.ServerException
- if failRobot.mouseWheel(int)
protected java.lang.Object setMillisBetweenKeystrokes(java.lang.String[] params) throws java.rmi.ServerException
params
- String[]
field[0] int milliseconds between keystrokes delay.
java.rmi.ServerException
- on failure.Robot.setMillisBetweenKeystrokes(int)
protected java.lang.Object setWaitReaction(java.lang.String[] params) throws java.rmi.ServerException
params
- String[]
params[0] wait boolean, if wait or not. params[1] 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. params[2] dealyForToken int, The delay in millisecond to wait the reaction after input-keys for the string as long as a token. params[3] dealy int, The constant delay in millisecond to wait the reaction after input-keys.
java.rmi.ServerException
- on failure.Robot.setWaitReaction(boolean)
,
Robot.setWaitReaction(boolean, int, int, int)
protected java.lang.Object typeKeys(java.lang.String[] params) throws java.rmi.ServerException
params
- String[]
field[0] String input string.
java.rmi.ServerException
- on failure.Robot.inputKeys(String)
protected java.lang.Object typeChars(java.lang.String[] params) throws java.rmi.ServerException
params
- String[]
field[0] String input string.
java.rmi.ServerException
Robot.inputChars(String)
protected java.lang.Boolean clearClipboard() throws java.rmi.ServerException
java.rmi.ServerException
Robot.clearClipboard()
protected java.lang.Boolean setClipboard(java.lang.Object... params) throws java.rmi.ServerException
params
- Object...
field[0] String content string to set to clipboard.
java.rmi.ServerException
Robot#setClipboard(String)}
protected java.lang.Object getClipboard(java.lang.Object... params) throws java.rmi.ServerException
params
- Object...
field[0] DataFlavor the type of the content to get from clipboard
java.rmi.ServerException
Robot#getClipboard(DataFlavor)}
public java.lang.Object runCommand(java.lang.Object commandAndParameters) throws java.rmi.RemoteException, java.lang.Exception
SeleniumRMIServer
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 SeleniumRMIServer
commandAndParameters
- -- usually a String.
String commandAndParameters interpreted as:
char[0] field separator for all subsequent fields field[1] -- command field[2-N] -- command parameters
java.rmi.ServerException
- if an error occurs or the requested command is not supported.java.rmi.RemoteException
java.lang.Exception
public java.lang.Object execute(java.lang.Object command, java.lang.Object... parameters) throws java.rmi.RemoteException, java.lang.Exception
SeleniumRMIServer
The parameters should be Serializable.
execute
in interface SeleniumRMIServer
command
- -- usually a String representing the action's nameparameters
- Object..., serializable parametersjava.rmi.ServerException
- if an error occurs or the requested command is not supported.java.rmi.RemoteException
java.lang.Exception
public static void main(java.lang.String[] args)
Note: For consistent operation the property java.rmi.server.hostname
needs to be set in code or
on the command line before launching an RMI Server:
-Djava.rmi.server.hostname=<rmi server ip>
-Djava.rmi.server.hostname=hostname.company.internal.net
Note: Normally Java exports a new RMI Object object using an anonymous port. If you want an explicit port,
please set property server.port
in code or on the command line:
-Dserver.port=<RMI server port>
System.setProperty("server.port", "8900");
Note: Normally Java creates a registry Object object using a konwn port 1099
.
If you want an other port for the registry, please set property registry.port
in code
or on the command line:
-Dregistry.port=<Remote Registry port>
System.setProperty("registry.port", "1100");
Copyright © SAS Institute. All Rights Reserved.