How to setup Selenium Grid in Docker | Using Docker Compose yml file | Part 2

Published: 04 March 2021
on channel: Maximum Automation
5,961
28

In this video we are going to see that how to execute your test on selenium grid which is created using docker.

Add the below code to create the webdriver object to run the execution on remote machine.

ChromeOptions option = new ChromeOptions();
try {
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),option);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


If you run the test then you can see the message that a session has been created with the remote machine. And you test will get execute.

Now lets say that you want to debug your execution while running it on the remote machines.
And to do that you need to login into the docker container where the execution is running....

So first you can download the vnc viewer from realvnc website.
once you're done with installation then you can open the vnc viewer to connect to the docker container..

Before connecting to the container, you have change the images used for browser during grid setup.

So you have to pull a new image for creating container for chrome, with the name selenium/node-chrome-debug.

docker pull selenium/node-chrome-debug

So when you will run the container using this image, then vnc server is also gonna run on the same container.

Stop the selenium grid setup by typing the below command

docker-compose down...

And then update the image name for chrome in docker-compose.yml file, selenium/node-chrome-debug.

After that type the below command to setup the grid again.

docker-compose up

Thenconnect to the container using vnc viewer.
open the vnc viewer -- go to file -- new connection.

then type the container address as localhost:9001 and provide any name to this container and save it.

now to connect to the container you can type the password as secret.

Then run the test again, and you will see that execution is running on chrome browser which is inside a docker container.

Using this method you can always use to debug your test.


**********Please comment in case of any query.**************

Also, please see other videos as well.

How to setup selenium grid in docker Part1 :    • How to setup Selenium Grid in Docker ...  

How to setup selenium grid in docker-Part2    • How to setup Selenium Grid in Docker ...  

Selenium with C# - Klov Report :    • Selenium with C# | Klov Report Server  

Selenium with C# - Extent Report :    • Selenium with C# | Extent Report  

Selenium with C# - Create Project to automate test (Selenium + Specflow ) :    • Video  

Selenium with C# - Parallel Execution and Screenshot :    • Video  

Selenium with C# - All about feature files :    • Video  

Serilog - Logging in Automation Framework :    • Serilog | Logging in Automation Frame...  

Selenium with C# - Specflow - External Bindings :    • Selenium C# | Specflow | External Bin...  

Selenium - Working with Excel - Part 1 :    • Video  

Selenium with Java - Cucumber Html Report :    • Selenium with Java | Cucumber Html Re...  

Object Repository | YAML file | Selenium JAVA | BDD Framework -    • Object Repository | How to maintain O...  


Watch video How to setup Selenium Grid in Docker | Using Docker Compose yml file | Part 2 online without registration, duration hours minute second in high quality. This video was added by user Maximum Automation 04 March 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 5,961 once and liked it 28 people.