Before this please go through
https://automationknowledgesharing2020.blogspot.com/2020/08/dockerlearning.html
https://automationknowledgesharing2020.blogspot.com/2020/08/selenium-gridhub-node.html
Selenium grid helps to run our test cases in different operating systems and on different browsers.
Prerequisites:
Given below are a few things we need to check:
- If your machine consists of JDK 1.7 or later version
- Is Chrome and Firefox browsers installed on your local machine?
- Selenium WebDriver and TestNG based test cases.
- Configured Testng.xml file to run test cases as parallel tests.
Please refer blog
After the above set-up,lets pull required images from
Image | Command |
---|
Selenium hub | docker pull selenium/hub |
Selenium firefox node | docker pull selenium/node-firefox |
Selenium chrome node | docker pull selenium/node-chrome |
Selenium firefox debug | docker pull selenium/node-firefox-debug |
Selenium chrome debug | docker pull selenium/node-chrome-debug |
After pull
To Start Selenium Hub
docker run -d -p 4444:4444 --name selenium-hub selenium/hub
after you execute,
Type below in your browser
check logs for
docker ps
docker logs 5af807482646
Lets Start Chrome and Firefox node,
docker run -d --link selenium-hub:hub selenium/node-chrome
docker run -d --link selenium-hub:hub selenium/node-firefox
Refresh below url,
Command to run chrome debug node from Docker
docker run -d -P --link selenium-hub:hub selenium/node-chrome-debug
docker run -d -P --link selenium-hub:hub selenium/node-firefox-debug
C:\Users\manjunathk\selenium>docker ps -a
Nodes | Running Port Numbers |
---|
Chrome debug node | 32769 |
Firefox debug node | 32768 |
Now, we know the port numbers of chrome and firefox debug nodes that are running.
Now, we know the port numbers of chrome and firefox debug nodes that are running so we can start both the browsers using VNC viewer.
For that we need to follow the steps given below:
1) Download VNC viewer from their official site: Download VNC
2) Run it
3) Type the hub URL and the port number of each debug mode as shown below and click on the connect button
HUB URL: PORT NUMBER
- For Chrome browser 192.168.99.100:32771
4) After clicking on the connect button VNC viewer will ask for a password. By default the password for VNC viewer is secret, type the password as secret and click Ok and you will be able to see a window for the chrome browser.
5) Likewise, you have to do the same for the Firefox browser by using a VNC viewer. Open the VNC application on your local computer and use Firefox running port number with the hub URL and click the connect button.
- For Firefox browser 192.168.99.100:32772
Again you will see another window opening for the Firefox browser.
see logs
13:50:27.686 INFO [DefaultRemoteProxy.onEvent] - Marking the node http://172.17.0.3:5555 as down: cannot reach the node for 2 tries
13:50:31.655 INFO [DefaultRemoteProxy.onEvent] - Marking the node http://172.17.0.4:5555 as down: cannot reach the node for 2 tries
13:51:32.197 INFO [DefaultRemoteProxy.onEvent] - Unregistering the node http://172.17.0.3:5555 because it's been down for 64511 milliseconds
13:51:32.197 WARN [DefaultGridRegistry.removeIfPresent] - Cleaning up stale test sessions on the unregistered node http://172.17.0.3:5555
13:51:36.169 INFO [DefaultRemoteProxy.onEvent] - Unregistering the node http://172.17.0.4:5555 because it's been down for 64514 milliseconds
13:51:36.169 WARN [DefaultGridRegistry.removeIfPresent] - Cleaning up stale test sessions on the unregistered node http://172.17.0.4:5555
13:53:24.807 INFO [DefaultGridRegistry.add] - Registered a node http://172.17.0.4:5555
13:53:24.897 INFO [DefaultGridRegistry.add] - Registered a node http://172.17.0.3:5555
14:00:34.032 INFO [DefaultGridRegistry.add] - Registered a node http://172.17.0.5:5555
14:00:51.277 INFO [DefaultGridRegistry.add] - Registered a node http://172.17.0.6:5555
14:04:21.183 INFO [DefaultGridRegistry.add] - Registered a node http://172.17.0.8:5555
14:04:21.226 INFO [DefaultGridRegistry.add] - Registered a node http://172.17.0.7:5555
14:05:13.629 INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browserName: chrome, platform: LINUX}
14:05:13.630 INFO [TestSlot.getNewSession] - Trying to create a new session on test slot {server:CONFIG_UUID=e6182590-23f0-4477-9f5f-0888750e64bc, seleniumProtocol=WebDriver, browserName=chrome, maxInstances=1, platformName=LINUX, version=84.0.4147.105, applicationName=, platform=LINUX}
C:\Users\manju
To run selenium grid test, watch,
https://automationknowledgesharing2020.blogspot.com/2020/08/selenium-gridhub-node.html