# 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:

- To run tests against multiple browsers, multiple versions of a browser, and browsers running on different operating systems.
- To reduce the time it takes for a test suite to complete a test pass.

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/](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

- Navigate to the Chrome driver [download](https://chromedriver.chromium.org/) page and download the _chromedriver_mac64.zip_ file, then extract it.

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

- Navigate to the Firefox driver [download](https://github.com/mozilla/geckodriver/releases) page and download the _geckodriver-v0.26.0-macos.tar.gz_ file and extract it.

- Beginning with Safari 10 on macOS X El Capitan and macOS Sierra, Safari comes bundled with a new driver implementation that’s maintained by the Web Developer Experience team at Apple. Safari’s driver is launchable via the `/usr/bin/safaridriver`

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

- After downloading and extracting the Chrome driver, you need to move it to the `/usr/local/bin` folder to run the Chrome and Firefox test

**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>```<br>mv chromedriver /usr/local/bin<br>```<br>```<br>mv geckodriver /usr/local/bin<br>```<br>#### From the user interface, open a new **Finder** window:<br>- From the top menu, select **Go > Go to Folder**<br>- Type `/usr/local/bin` and click **Go**<br>- Copy the `chromedriver` file to the bin folder.<br>- Copy the `geckodriver` file to the bin folder |

### 4. Configurations for Safari

- Ensure that the **Develop** menu is available. It can be turned on by opening Safari **Preferences** in the menu bar, **Safari**  **Preferences** > **Advanced** tab, and confirm that the _Show Develop menu in menu bar_ checkbox is checked.
- Enable **Remote Automation** in the **Develop** menu. This is toggled via **Develop** > **Allow Remote Automation** in the menu bar.
- Authorize `safaridriver` to launch the `webdriverd` service which hosts the local webserver. To permit this, run `/usr/bin/safaridriver` once manually and complete the authentication prompt.

```
         safaridriver /usr/bin/safaridriver --enable
```

- Enter the _password_ and you're done.

## 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](https://leapworkaps.file.force.com/sfc/dist/version/download/?oid=00D7Q000003Qjj6&ids=0687Q000004sAhu&d=%2Fa%2F7Q000000cAi4%2F4DK61gVSiglwfkJ02rdjFMmgqfYp1qXNa7LeEU.HIM8&asPdf=false) 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](https://support.leapwork.com/s/article/Web-Browser-and-Driver-Compatibility-Matrix) 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?](https://support.leapwork.com/s/article/HowtosetupSeleniumGrid63307362113ef) 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](https://support.leapwork.com/hc/en-us/articles/115001195971#h_7531894261513171426411).

**Attachments:**

[SeleniumGrid.zip](https://leapworkaps.file.force.com/sfc/dist/version/download/?oid=00D7Q000003Qjj6&ids=0687Q000004sAhu&d=%2Fa%2F7Q000000cAi4%2F4DK61gVSiglwfkJ02rdjFMmgqfYp1qXNa7LeEU.HIM8&asPdf=false)
