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.
At least 2 Machines. One acting as Hub Server and Node and another machine will be used to run the test.
Machine 2 – Selenium Tests i.e your selenium project( can be java project or c# solution)
On remote machine download SeleniumServer and chromedriver and copy it in a folder example e:\seleniumserv
Launch SeleniumServer HUB
from command prompt run the following command
java -jar E:\SeleniumServ\selenium-server-4.1.2.jar hub
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
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
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
- If firewall is on, make sure to add exception for the port number used and java app.
- 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