Selenium grid on mac article describes how to install the selenium grid on your MAC. I will also share a very basic test code to test the selenium grid on your MAC operating system. Let’s start!
What is Selenium Grid?
Selenium Grid allows you to:
- Scale by distributing tests on several machines ( parallel execution )
- Manage multiple environments from a central point, making it easy to run the tests against a vast combination of browsers / OS.
- Minimize the maintenance time for the grid by allowing you to implement custom hooks to leverage virtual infrastructure for instance.
Now, please go to http://www.seleniumhq.org/download/ and download Selenium Standalone Server. Selenium team constantly updating the versions. You may see a different version, pls do not panic, just download it. ;)
Then, create a seleniumgrid folder under Documents and copy the .jar file under the Documents > seleniumgrid folder as you see below.
What are Hub and Nodes?
Basically, we have a Hub which is a server that we connect from our tests and we have Nodes, they can be on different machines and they register with the hub. Simply, we have a hub and several nodes, nodes are registered our hub and hub knows that which browsers are available. Hub sends requests to the nodes based on desired capabilities and executes the tests.
How to Start and Configure Hub and Nodes on MAC
First, download the hub and node config files from below addresses.
Hub Config:
{ "port": 4444, "newSessionWaitTimeout": -1, "servlets" : [], "withoutServlets": [], "custom": {}, "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher", "registry": "org.openqa.grid.internal.DefaultGridRegistry", "throwOnCapabilityNotPresent": true, "cleanUpCycle": 5000, "role": "hub", "debug": false, "browserTimeout": 0, "timeout": 1800 }
Node Config:
{ "capabilities": [ { "browserName": "firefox", "marionette": true, "maxInstances": 5, "seleniumProtocol": "WebDriver" }, { "browserName": "chrome", "maxInstances": 5, "seleniumProtocol": "WebDriver" }, { "browserName": "internet explorer", "platform": "WINDOWS", "maxInstances": 1, "seleniumProtocol": "WebDriver" }, { "browserName": "safari", "technologyPreview": false, "platform": "MAC", "maxInstances": 1, "seleniumProtocol": "WebDriver" } ], "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", "maxSession": 5, "port": -1, "register": true, "registerCycle": 5000, "hub": "http://localhost:4444", "nodeStatusCheckTimeout": 5000, "nodePolling": 5000, "role": "node", "unregisterIfStillDownAfter": 60000, "downPollingLimit": 2, "debug": false, "servlets" : [], "withoutServlets": [], "custom": {} }
Save them as hub.json and node.json under seleniumgrid folder.
How to start Selenium Grid on MAC?
Then save below script as startgrid.command this script automatically starts node and hub.
But before you need to install a chrome driver on your MAC. For this, please check this article.
#! /bin/bash osascript -e 'tell app "Terminal" do script "cd Documents/seleniumgrid/ && java -jar selenium-server-standalone.jar -role hub -hubConfig hub.json" end tell' osascript -e 'tell app "Terminal" do script "cd Documents/seleniumgrid/ && java -jar -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver selenium-server-standalone.jar -role node -nodeConfig node.json" end tell'
Note: If you also download and move the firefox driver (geckodriver) to the /usr/local/bin folder, you can use below script. It registers both Firefox and Chrome drivers.
#! /bin/bash osascript -e 'tell app "Terminal" do script "cd Documents/seleniumgrid/ && java -jar selenium-server-standalone.jar -role hub -hubConfig hub.json" end tell' osascript -e 'tell app "Terminal" do script "cd Documents/seleniumgrid/ && java -jar -Dwebdriver.gecko.driver=/usr/local/bin/geckodriver -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver selenium-server-standalone.jar -role node -nodeConfig node.json" end tell'
Then when you run below script both hub and node will be run.
./startgrid.command
Now, we can check the selenium grid is working on MAC. In order to do that, open a chrome browser and go to this link: http://localhost:4444/grid/console
You should see the below window which means grid works properly.
When you run below project it will run and it will use one of the chrome browsers of the grid.
GitHub Project for Basic Selenium Grid Test: https://github.com/swtestacademy/basicseleniumgridproject
Thanks.
Onur Baskirt

Onur Baskirt is a Software Engineering Leader with international experience in world-class companies. Now, he is a Software Engineering Lead at Emirates Airlines in Dubai.
downloaded the selenium server but didnt get any other files (hub etc..)
You can not get those files from the selenium server download. Would you kindly read the whole article that I described as follows:
How to Start and Configure Hub and Nodes on MAC
First, download the hub and node config files from below addresses.
Hub Config: https://github.com/SeleniumGridRefactor/grid/blob/master/src/main/resources/org/openqa/grid/common/defaults/DefaultHub.json
Node Config: https://github.com/SeleniumGridRefactor/grid/blob/master/src/main/resources/org/openqa/grid/common/defaults/DefaultNodeWebDriver.json
Hi Kept the same structure, But while running ./startgrid.command, It says command not found
Alright, it’s working for me now. Some issues with permissions
Happy to hear that Sumit. Well done! :)
I am facing 404
Hub Config: https://github.com/SeleniumHQ/selenium/blob/master/java/server/src/org/openqa/grid/common/defaults/DefaultHub.json
Node Config: https://github.com/SeleniumHQ/selenium/blob/master/java/server/src/org/openqa/grid/common/defaults/Defau
I added configs to the page.
Hi. When I try to run the script to run the Hub and Node, I get permission denied.
-bash: ./startgrid.command: Permission denied
Hi, I think it is about file and folder permission. You need to try chmod command to give 777 permission to your file. https://superuser.com/questions/285270/setting-chmod-777-on-folder-using-mac-terminal
try this ‘chmod +x ./startgrid.command’ in terminal
Can we provide multiple instances of Safari on Mac?
What if we want to run for appium?
Hi Sam,
You can check these articles:
https:/appium-paralllel-testing
https:/appium-parallel-tests-on-multiple-emulators/