Selenium Standalone Server Example

1. Introduction

With this example we are going to demonstrate how to use and configure Selenium standalone servers (Selenium Grid). We are going to run the hub server and the two nodes. Each nodes will run the tests in different browsers.

Selenium Grid are the servers which compounds in distributed nodes. It offers you to run your selenium test on separate machines in different kinds environments. This is great opportunities, because your tests can run parallels and use different browsers for testing.

2. High level architecture

Below is shown high level architecture. It has the follow flow process. First we pass the tests to hub which send this tests to specific nodes where all tests will be executed.

Selenium Grid. High level
Selenium Grid. High level architecture

So all tests and nodes can be located on different machines. Such architecture can be scaled easily.

3. Configuration

Before we can start to configure the Selenium Grid we should download the necessary library. Selenium Grid consists only from one JAR file. Go to the official site link and download the Selenium Server JAR file – selenium-server-standalone-2.48.2.jar. This jar has the good help information. We should run this jar with the key -h that to print help information on screen.

java -jar selenium-server-standalone-2.48.2.jar -h

This help information has all explanation about supported keys. This keys are used for configuration the instance server. First of all we should run this jar with key –role hub. It means the this instance will be the hub server. It will be taken all receiving tests and distributed to the specific nodes server. The hub server is run on 4444 port by default.

C:\Tools>java -jar selenium-server-standalone-2.48.2.jar -role hub
10:29:14.270 INFO - Launching Selenium Grid hub
2015-11-19 10:29:15.458:INFO::main: Logging initialized @1362ms
10:29:15.479 INFO - Will listen on 4444
10:29:15.563 INFO - Will listen on 4444
2015-11-19 10:29:15.568:INFO:osjs.Server:main: jetty-9.2.z-SNAPSHOT
2015-11-19 10:29:15.631:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletC
2015-11-19 10:29:15.770:INFO:osjs.ServerConnector:main: Started ServerConnector@
2015-11-19 10:29:15.771:INFO:osjs.Server:main: Started @1675ms
10:29:15.772 INFO - Nodes should register to
10:29:15.772 INFO - Selenium Grid hub is up and running

The secondary step is to run the node instance. It can be done with key -role node as shown below. The same time we should point where is located our hub server by key -hub http://localhost:4444/grid/register

C:\Tools>java -jar selenium-server-standalone-2.48.2.jar -role node  -hub http:/
10:31:08.635 INFO - Launching a Selenium Grid node
10:31:09.999 INFO - Java: Oracle Corporation 25.45-b02
10:31:10.000 INFO - OS: Windows 7 6.1 x86
10:31:10.009 INFO - v2.48.0, with Core v2.48.0. Built from revision 41bccdd
10:31:10.089 INFO - Driver class not found:
10:31:10.090 INFO - Driver provider is not re
10:31:10.153 INFO - Selenium Grid node is up and ready to register to the hub
10:31:10.215 INFO - Starting auto registration thread. Will try to register ever
y 5000 ms.
10:31:10.216 INFO - Registering the node to the hub: http://localhost:4444/grid/
10:31:10.254 INFO - The node is registered to the hub and ready to use

How you can see above the configuration process can be done by adding the keys in command line. But Selenium Server supports another variant of configuration by file configuration in JSON format.

Firstly we should create the file which has the name – firefox_node.json. It can have any appropriate name.

          "browserName": "*firefox",
          "maxInstances": 1,
          "seleniumProtocol": "WebDriver"
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "maxSession": 5,
    "port": 6543,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4444,

We pointed there that all tests should be run in firefox. Now we can run the new node instance with this configurations. We use -nodeConfig that to point which config file to use.

C:\Tools>java -jar selenium-server-standalone-2.48.2.jar -role node -nodeConfig
11:36:22.804 INFO - Launching a Selenium Grid node
11:36:23.789 INFO - Java: Oracle Corporation 25.45-b02
11:36:23.789 INFO - OS: Windows 7 6.1 x86
11:36:23.798 INFO - v2.48.0, with Core v2.48.0. Built from revision 41bccdd
11:36:23.884 INFO - Driver class not found:
11:36:23.885 INFO - Driver provider is not re
11:36:23.973 INFO - Selenium Grid node is up and ready to register to the hub
11:36:24.028 INFO - Starting auto registration thread. Will try to register ever
y 5000 ms.
11:36:24.029 INFO - Registering the node to the hub:
11:36:24.041 INFO - The node is registered to the hub and ready to use

Sometimes you can need only one instance server. For this reason you should run the selenium server without keys.
All tests will be executed in this instance in this case.

Another good opportunities are configure special browsers. For example, below we set the chrome browser environment.

Single Selenium Instance. Chrome Config.
Single Selenium Instance. Chrome Config.

We set the properties :"c:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

Right now we have the three instances: one the hub and two nodes and one single server. Let’s start to run our tests.

4. Run tests

First of all we should create the new maven project.


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""



That we need to add the simple tests.


package ru.parsentev;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;


import static;
import static org.junit.Assert.assertThat;

 * Tests for selenium standalone server.
 * @author parsentev
 * @since 19.11.2015
public class SeleniumStandaloneServerTest {

	public void executeFirefoxDriver() throws MalformedURLException {

	public void executeChrome() throws MalformedURLException {

	private void execute(final DesiredCapabilities capability) throws MalformedURLException {
		WebDriver driver = new RemoteWebDriver(
				new URL("http://localhost:4444/wd/hub"), capability
		WebElement element = driver.findElement("s"));
				is("You searched for selenuim | Java Code Geeks")

Now we can run the our test.

mvn clean test

We can see details information about tests process on the node logs or screens. You should see somethings similar:

12:14:25.891 INFO - Executing: [new session: Capabilities [{browserName=firefox,
 version=, platform=ANY}]])
12:14:25.903 INFO - Creating a new session for Capabilities [{browserName=firefo
x, version=, platform=ANY}]
12:14:30.143 INFO - Done: [new session: Capabilities [{browserName=firefox, vers
ion=, platform=ANY}]]
12:14:30.196 INFO - Executing: [get:])
12:14:34.283 INFO - Done: [get:]
12:14:34.299 INFO - Executing: [find element: s])
12:14:34.671 INFO - Done: [find element: s]
12:14:34.689 INFO - Executing: [send keys: 0 [[FirefoxDriver: firefox on WINDOWS
 (2ca50141-8460-4012-bec4-b291e4042f55)] -> name: s], [selenuim]])
12:14:34.774 INFO - Done: [send keys: 0 [[FirefoxDriver: firefox on WINDOWS (2ca
50141-8460-4012-bec4-b291e4042f55)] -> name: s], [selenuim]]
12:14:34.784 INFO - Executing: [submit: 0 [[FirefoxDriver: firefox on WINDOWS (2
ca50141-8460-4012-bec4-b291e4042f55)] -> name: s]])
12:14:39.270 INFO - Done: [submit: 0 [[FirefoxDriver: firefox on WINDOWS (2ca501
41-8460-4012-bec4-b291e4042f55)] -> name: s]]
12:14:39.281 INFO - Executing: [get title])
12:14:39.311 INFO - Done: [get title]
12:14:39.327 INFO - Executing: [delete session: a459baef-2980-4fcc-8093-4ff4eecb
12:14:39.806 INFO - Done: [delete session: a459baef-2980-4fcc-8093-4ff4eecbf03f]

When the test is received by node it looks appropriate browser in local machine. Then the node opens this browser and starts to do the tests.

It can look like below:

Firefox selenium tests
Firefox selenium tests
Chrome selenium tests
Chrome selenium tests

5. Download the Code Project

You can download the full source code of this example here: Selenium

Want to know how to develop your skillset to become a Java Rockstar?

Join our newsletter to start rocking!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area

I have read and agree to the terms & conditions


Petr Arsentev

Petr Arsentev has over 8 years of experience in java development. He participated in the development a few startup projects, which run successfully. He finished Moscow Power Engineering Institute (National Research University) at 2009. After he started to work in a local company as java developer and still keeps improving the knowledge about software developments. He focused on JVM languages like Java, Scala and related technologies and frameworks. He has developed the few courses about Java in Russian. He teaches students Java language too. This is his personal website
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments
5 years ago

Selenium testing is one of the best framework for testing the web applications. You can easily automate your test to find the bugs at early stage

4 years ago

Thank you for this very example. Selenium automates browsers. That’s it! What you do with that power is entirely up to you. I love it and I like that Grid is still in use, and works with both WebDriver and RC. I’m firm on that Selenium is the present and the future of automated browser management. If you want to be considered a professional in the field of automated testing of web applications – it is essential for you to own this tool.

4 years ago

Needed to compose one simple thing yet thanks for the suggestions that you are contributed here. Would like to read this blog regularly to get more updates regarding selenium

3 years ago

Thank you for the valuable information.

Back to top button