Enter the Matrix: Selenium grid made simple
As I discussed in ‘Driver factory part 3 – Remotewebdrivers and my very own grid’ I found that it was pretty painless to set up a grid hub and node on a single Windows machine. Whilst the grid was itself perfectly stable, it is a bit of a pain to start up multiple command prompts and run individual nodes etc.
There were two obvious improvements to this that I could try:
- Work out how to configure multiple browsers on a single node.
- Use Powershell to launch hub and node from a single point.
Multiple browsers on a single hub.
It is pretty obvious that this works as it is the default configuration if you do not specify any configuration. Previously I had configured each browser on its own node requiring its own command to start it, and command window to control and log the results. I was sure I could do better.
How hard could it be?
Well as expected, it is pretty simple. In this case I am going to describe how I did it on Windows using powershell, but it would be just as simple on MacOs or linux. As a reminder, you just need the the webdriver binaries for your browsers and platform as well as the selenium standalone server jar. For convenience I put them all in ‘C:/Grid’ and I added this directory to the windows System path.
- Starting with a nodeconfig.json.
{
"capabilities":
[
{
"browserName": "operablink",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"webdriver.opera.driver": "C:/Grid/operadriver.exe"
},
{
"browserName": "firefox",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"webdriver.gecko.driver": "C:/Grid/geckodriver.exe"
},
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"webdriver.chrome.driver": "C:/Grid/chromedriver.exe"
},
{
"browserName": "internet explorer",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"webdriver.ie.driver": "C:/Grid/IEDriverServer.exe"
},
{
"browserName": "MicrosoftEdge",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"webdriver.edge.driver": "C:/Grid/MicrosoftWebDriver.exe"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "http://localhost:4444",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
The node launch command then becomes:
java -jar "C:\Grid\selenium-server-standalone-3.8.1.jar" -port 5560 -role node -hub http://localhost:4444/grid/register -nodeConfig "C:\Grid\nodeconfig.json"
Launch from one command
- To launch both hub and node from a single place, we can just call the commands from a 2 line powershell script
Start-Process powershell {java -jar "C:\Grid\selenium-server-standalone-3.8.1.jar" -role hub}
Start-Process powershell {java -jar "C:\Grid\selenium-server-standalone-3.8.1.jar" -port 5560 -role node -hub http://localhost:4444/grid/register -nodeConfig "C:\Grid\nodeconfig.json"}
That’s all there is to it. Run the powershell script and both hub and node will launch.

Progress made this week:
- Streamlined the grid launch process into a single powershell script.
Lessons learnt:
- Launching the grid could hardly be easier.
- Opera still won’t launch on the grid despite much research and many attempts.