Selenium Grid setup for Remote execution

Why do you need Selenium Grid setup for remote execution?

Scenario1 – You need to run your selenium automation tests with different browser/OS combination
Scenario2 – You need to run selenium tests in parallel across different or same browsers
…..
There can be many more reasons when you need your selenium tests to run on a remote machine. For this selenium provides Grid support.

Below are step by step approach to Selenium Grid setup for Remote execution.

Prerequisite

At least 2 Machines. One acting as Hub Server and Node and another machine will be used to run the test.

Machine 1 – Remote machine need to have Java runtime SeleniumServer and chromedriver.

Machine 2 – Selenium Tests i.e your selenium project( can be java project or c# solution)

Step 1

On remote machine download SeleniumServer and chromedriver and copy it in a folder example e:\seleniumserv

Step 2

Launch SeleniumServer HUB

from command prompt run the following command

java -jar E:\SeleniumServ\selenium-server-4.1.2.jar hub

Hub execution


Step3

Next step is to register node to the Hub. To do that run the following command.

java -jar E:\SeleniumServ\selenium-server-4.1.2.jar node 
node register

We can now check if the node is correctly registered by opening the url http://localhost:4444/ui/index.html

Similarly we can register more nodes to the Hub

Step 4

Now we can run our test from machine 2. Browser will be launched from machine 1 and all the tests will run from the remote machine.

Some points to note during Selenium Grid setup for Remote execution

  1. If firewall is on, make sure to add exception for the port number used and java app.
  2. Also, make sure your selenium test uses RemoteWebdriver instead of ChromeDriver and the test should pass the hub url as

eg: RemoteWedriver driver;

driver =new RemoteWebDriver(new URL("http://192.168.1.16:4444/wd/hub"));

If you need some more details on basic selenium scripts refer my other posts likes Multi browser testing using Visual Studio

Leave a Reply

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