Wednesday, November 27, 2019

How Selenium grid can be established for Protractor Solutions?

In this we are going to look into how we can use the selenium grid for parallel execution of the Protractor tests.

Using the selenium grid we can achieve parallel test execution across different browsers, OS, machines, which in turn saves a lot of our time.

The steps to follow are:

1.Download the latest Selenium Standalone Server https://selenium.dev/downloads/




2.Copy this file to a safe folder and open the command prompt.Change the working folder to the path where the selenium standalone server exists.









3.Now execute the below command:

java -jar selenium-server-standalone-3.141.59.jar -role hub








Now we can see that the selenium hub is up and running. So the nodes should connect to this ip address or machine.

Now if you want check see how many machines are connected to this hub you simply browse using the ip address: http://192.168.29.223:4444/grid/console .

4. Next step would be to establish the connection from node to grid.For this download the selenium standalone server and the browser driver to the node machine.





5.Now open the command prompt change the working folder to the path where both driver and selenium server exists.

Here I am using the same machine as hub and node. So I will open another instance of command prompt.I will change the working folder to the same path C:\SeleniumAuto

java -Dwebdriver.chrome.driver="driver path" -jar selenium-server-standalone-3.141.59.jar -role node -hub "ip adress of machine"

java -Dwebdriver.chrome.driver="C:\SeleniumAuto\chromedriver_78.exe" -jar selenium-server-standalone-3.141.59.jar -role node -hub http://192.168.29.223:4444/wd/hub

Once run the command, we can see the the node is registered:


Now if hub machine cmd, you will able to see that a node has be registered.

Now if we refresh the browser then we can see that a node has been registered:


The same steps can be 4 and 5 can be repeated for any number of nodes.

Here I have used rand ports to register the node. We can specify the ports for the nodes and hub if there any security issues. For example:

1.Node:

java -Dwebdriver.chrome.driver="C:\SeleniumAuto\chromedriver_78.exe" -jar selenium-server-standalone-3.141.59.jar -role node -hub http://192.168.29.223:4444/wd/hub -port -5555

Simillarly add  port in Hub too.

Once all the nodes are registered your grid is ready, up and running.Now you are good to run your tests.





No comments:

Post a Comment