Launching Selenium Grid and Registering a Web Node
Launching Selenium Grid:
Tips:
Registering a Chrome Browser Web Node:
- 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
- Open browser and navigate to "http://localhost:4444/grid/console" to check if the grid is up and running.
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
- 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
- Open browser and navigate to "http://localhost:4444/grid/console" to check if the node is registered successfully.
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
Post a Comment