How to configure Selenium Grid on MAC to run Safari, Chrome and Firefox Automation

How to configure Selenium Grid on MAC to run Safari, Chrome and Firefox Automation

Selenium Grid is used to speed up the execution of a test by using multiple machines to run tests in parallel. It is also used to support running tests against multiple environments, specifically, against different browsers at the same time. You can use Selenium Grid in the following scenarios:

Use this article as a step-by-step guide for setting up the Selenium Grid.

Download and Configurations

Download Selenium Standalone Server, Chrome, Safari, and Firefox drivers, then configure your Mac machine to run a Safari test. The following steps explain the process:

1. Download Selenium Server

Download the Selenium Server jar file from Selenium’s official website, formerly known as Selenium RC Server, and save it to any location on your local disk.

Visit the Selenium HQ download page at http://www.seleniumhq.org/download/

You should see a similar file to selenium-server-standalone-3.141.59.jar in the download folder once the download is completed.

2. Download the Chrome and Firefox driver

Below snapshot is just for reference purpose, always download the latest driver from the above given landing page.

3. Configure Chrome, Firefox, and Safari drivers for automation

Choose your method from the following two options:

#### From a command-line interface, navigate to the folders where you've extracted the Chrome and Gecko driver and run the following commands:
<br>mv chromedriver /usr/local/bin<br>
<br>mv geckodriver /usr/local/bin<br>
#### From the user interface, open a new Finder window:
- From the top menu, select Go > Go to Folder
- Type /usr/local/bin and click Go
- Copy the chromedriver file to the bin folder.
- Copy the geckodriver file to the bin folder

4. Configurations for Safari

         safaridriver /usr/bin/safaridriver --enable

Running Selenium Hub and Node on Macs

Selenium Hub

The hub is the central server that manages nodes, takes instructions from the client and executes them remotely on the nodes, then manages test threads. Each Selenium Grid consists of one hub. The hub needs to be reachable from respective clients, for example, the CI server, developer machine, etc. The hub will connect to one or more nodes that tests will be delegated to.

Selenium Node

Nodes are Selenium instances that will execute tests on individual computer systems. There can be many nodes in a grid. A node on a Windows machine may have the capability of offering Internet Explorer as a browser option, whereas this wouldn't be possible on a Linux or Mac.

How to setup HUB:

To ease the configuration, download the attached SeleniumGrid.zip file, which contains all the required files, and extract the SeleniumGrid folder. Then copy the extracted Grid Setup folder to your Desktop.

Ensure that you have downloaded the compatible rivers and the correct Selenium Grid version to perform the setup procedures as previously listed.

N ote: Copy the compatible grid version to the SeleniumGrid folder and rename it to selenium-server-standalone.jar

Now, open Terminal and run the following command:

chmod u+x ~/Desktop/Selenium Grid/gridSetup.command

This will allow you to run the grid through the grid S etup . command script.

Double-clicking on the gridSetup.command script should open two command windows and run both the Selenium Hub and Node on your Mac machine.

Visit the How to setup Selenium Grid? article for information about Hub and Node configuration files and the execution process.

Configure your Leapwork environment to begin your first Selenium grid test using this article.

Attachments:

SeleniumGrid.zip