Remote WebDriver standalone server
This documentation previously locatedon the wiki
The server will always run on the machine with the browser you want totest. The server can be used either from the command line or through codeconfiguration.
Starting the server from the command line
Once you have downloadedselenium-server-standalone-{VERSION}.jar,place it on the computer with the browser you want to test. Then, fromthe directory with the jar, run the following:
java -jar selenium-server-standalone-{VERSION}.jarConsiderations for running the server
The caller is expected to terminate each session properly, callingeitherSelenium#stop() orWebDriver#quit.
The selenium-server keeps in-memory logs for each ongoing session,which are cleared whenSelenium#stop() orWebDriver#quit is called. Ifyou forget to terminate these sessions, your server may leak memory. Ifyou keep extremely long-running sessions, you will probably need tostop/quit every now and then (or increase memory with -Xmx jvm option).
Timeouts (from version 2.21)
The server has two different timeouts, which can be set as follows:
java -jar selenium-server-standalone-{VERSION}.jar -timeout=20 -browserTimeout=60- browserTimeout
- Controls how long the browser is allowed to hang (value in seconds).
- timeout
- Controls how long the client is allowed to be gonebefore the session is reclaimed (value in seconds).
The system propertyselenium.server.session.timeoutis no longer supported as of 2.21.
Please note that thebrowserTimeoutis intended as a backup timeout mechanismwhen the ordinary timeout mechanism fails,which should be used mostly in grid/server environmentsto ensure that crashed/lost processes do not stay around for too long,polluting the runtime environment.
Configuring the server programmatically
In theory, the process is as simple as mapping theDriverServlet toa URL, but it is also possible to host the page in a lightweightcontainer, such as Jetty, configured entirely in code.
- Download the
selenium-server.zipand unpack. - Put the JARs on the CLASSPATH.
- Create a new class called
AppServer.Here, we are using Jetty, so you will need todownloadthat as well:
importorg.mortbay.jetty.Connector;importorg.mortbay.jetty.Server;importorg.mortbay.jetty.nio.SelectChannelConnector;importorg.mortbay.jetty.security.SslSocketConnector;importorg.mortbay.jetty.webapp.WebAppContext;importjavax.servlet.Servlet;importjava.io.File;importorg.openqa.selenium.remote.server.DriverServlet;publicclassAppServer{privateServerserver=newServer();publicAppServer()throwsException{WebAppContextcontext=newWebAppContext();context.setContextPath("");context.setWar(newFile("."));server.addHandler(context);context.addServlet(DriverServlet.class,"/wd/*");SelectChannelConnectorconnector=newSelectChannelConnector();connector.setPort(3001);server.addConnector(connector);server.start();}}



