Skip to content

Selenium Grid 4

Simon Stewart edited this page Apr 24, 2019 · 2 revisions

THIS PAGE WILL BE UPDATED AS THE ALPHAS PROGRESS

Grid 4

The new Selenium server jar contains everything you need to run a grid. It's a single jar that contains every dependency, so can be run with java -jar selenium-server-4.0.0-alpha-1.jar.

Standalone Mode

The easiest mode to run the server in is "standalone". Just run:

java -jar selenium-server-4.0.0-alpha-1.jar standalone

The server will be listening on http://localhost:4444/, and that's the URL you should point remote WebDrivers to (that is, you no longer need to use http://localhost:4444/wd/hub) By default, the server will detect available drivers it can use (GeckoDriver, etc) by looking at the PATH You can use this mode just to make sure that things are working as you expect them to.

Hub and Node

Traditionally, the Grid has been run as two conceptual pieces: the Hub and one or more Nodes. To start the Hub:

java -jar selenium-server-4.0.0-alpha-1.jar hub

And the Node with:

java -jar selenium-server-4.0.0-alpha-1.jar node --detect-drivers

If you wish to run the hub and the node on different machines, start the node with:

java -jar selenium-server-4.0.0-alpha-1.jar node --detect-drivers --publish-events tcp://hub:4442 --subscribe-events tcp://hub:4443

Fully Distributed

Finally, you can start Grid 4 in a fully distributed manner, with each conceptual piece in its own process. First, start the session map (which is responsible for mapping session IDs to the node the session is running on):

java -jar selenium-server-4.0.0-alpha-1.jar sessions

Then the distributor:

java -jar selenium-server-4.0.0-alpha-1.jar distributor --sessions http://localhost:5556

And front the system with a router (the bit you would normally expose to the Web):

java -jar selenium-server-4.0.0-alpha-1.jar router --sessions http://localhost:5556 --distributor http://localhost:5553

The router will be listening to new session requests on http://localhost:4444.

Of course, right now, the Grid is utterly useless. Add a node to it:

java -jar selenium-server-4.0.0-alpha-1.jar node --detect-drivers

And you should now be good to go! curl http://localhost:4444/status should confirm this for you.

Using Docker

For now, the docker integration doesn't make use of UNIX domain sockets, so ensure your docker daemon is listening on port 2375:

socat -ls TCP-LISTEN:2375,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock

Once you've done this, then it's easy to start the selenium server and have it delegate to docker for creating new instances:

java -jar selenium-server-4.0.0-alpha-1.jar standalone -D selenium/standalone-firefox:latest '{"browserName": "firefox"}' --detect-drivers false

Or you can just start a node:

java -jar selenium-server-4.0.0-alpha-1.jar node -D selenium/standalone-firefox:latest '{"browserName": "firefox"}'

Accessing the UI

There is no UI right now, but you can always curl http://localhost:4444/status to get some interesting information out of the system --- the same information that we'll build the new UI using.

Clone this wiki locally