Launching Selenium Grid and Registering a Web Node

Launching Selenium Grid:
  • Download the latest version of Selenium Standalone Server from here.
  • Open command prompt and cd to the path where you downloaded the selenium server jar file from Step 1. Ex. "cd ~/Downloads"
  • Next we need to run the below command to start the selenium hub  (replace selenium-server-standalone-3.9.0.jar with the latest selenium server file name you downloaded)
java -jar selenium-server-standalone-3.9.0.jar -role hub -port 4444

  • Check for the success message "Selenium Grid hub is up and running" in the console



Tips:
  • Instead of doing cd to the selenium server file location and then running the command we can directly run the command by giving the absolute path of the selenium server jar file in the command
java -jar /home/nishant/Downloads/selenium-server-standalone-3.9.0.jar -role hub -port 4444

  • We can have multiple selenium server hubs by running the same command with different port number. This will be useful in scenarios where you want to maintain different Selenium Grids for Web and App
java -jar selenium-server-standalone-3.9.0.jar -role hub -port 4445 


Registering a Chrome Browser Web Node:
  • Ensure that the Grid is up and running
  • Download the latest version of chrome driver from here.
  • Open command prompt and cd to the path where you downloaded the selenium server and chromedriver file.
  • Now run the below command to register the Node to the Grid (replace selenium-server-standalone-3.9.0.jar with the latest selenium server file name you downloaded)
java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.9.0.jar -role webdriver -host 127.0.0.1 -hub http://127.0.0.1:4444/grid/register -port 5556 -maxSession 20 -browser browserName=chrome,maxInstances=20,platform=LINUX
  • Check for the success message "The node is registered to the hub and ready to use" in the console


Tips:
  • Instead of doing cd to the selenium server and chrome file location and then running the command we can directly run the command by giving the absolute path in the command
java -jar -Dwebdriver.chrome.driver=/opt/softwares/chromedriver /home/nishant/Downloads/selenium-server-standalone-3.9.0.jar -role webdriver -host 127.0.0.1 -hub http://127.0.0.1:4444/grid/register -port 5556 -maxSession 20 -browser browserName=chrome,maxInstances=20,platform=LINUX
  • To register a Firefox node, change the browserName value to firefox and remove the chrome.driver parameter
java -jar -Dwebdriver.gecko.driver=/opt/softwares/geckodriver /home/nishant/Downloads/selenium-server-standalone-3.9.0.jar -role webdriver -host 127.0.0.1 -hub http://127.0.0.1:4444/grid/register -port 5557 -maxSession 20 -browser browserName=firefox,maxInstances=20,platform=LINUX



Comments

Popular posts from this blog

Get rid of "Timed out receiving message from renderer"

Setup Selenium Grid using Kubernetes