How To Execute Selenium Test on Docker Container

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey Haven this is Mukesh Otani from blonde - Attribution calm so in this video we are going to talk about how you can execute your tests on docker container so in the previous we do is we have discussed what is docker how to install docker how we can setup selenium grid hub and node now everything is setup everything is up and running now the final step is to execute the test on docker so let's see what exactly we are going to cover in this video so first of all we will run our basic test on any of the container and we will actually see the containers and we'll see how it is running our tests so we'll try to run our test on two different containers one will be for Firefox one will be for Chrome and once we will complete this sequential execution we'll try to run two different tests on two different containers and we'll see how these tests are running parallel in two different containers so that's what we are going to cover in this video so let's get started okay so now everything is up and running we have a docker we have a house we have a two nodes connected to our house which is node Chrome I node Firefox we also logged it into the container and these containers are ready for us so the main thing is we need to see how we can run these tests right so before I jump into this topic I would request you to watch my previous video where we discussed about selenium grid okay because if you don't understand grid concept you will not understand this part so let me create a fresh package here called docker demo and let me create few tests this test I will run on a docker container so let's create a class called FF demo which is nothing but Firefox demo and I will create a method public void test app and I will give test an edition of testing G because we are going to use Justin G for this particular example now we have to create a desired capability object because we have to run test on a platform right so I will accept I will set a browser here and this time I will say I need browser type dot Firefox this is what I said that I need to run this on Firefox and now I will simply start so I will say web driver driver equal to new remote web driver so we use remote web driver whenever we have to run the test on a selenium grid so tool ask you the capability capability we already created right just now capped and for the remote address we have to use new URL and since our how is already running here I have to use this we don't have to use grid console's we'll give it a blue D slash hub it means we have driver hub so whenever we run any tests it will definitely trigger all the tests or it will bypass or it was simply forward all the requests to this particular hub and now it is have responsibility that it should pass our request with respect to node so let's say I just want to open any application download upload at google.com what I would to find element by name so we have our search query right that is actually Q so I will just type something learn Auto machine and I will say driver dart quit and I will do the quit after a long time because I want to see the executions I will put five seconds of wait so that I can see the execution okay so let's do one thing let's first check for Firefox which one we have it is three two seven six nine so three two seven six nine you can easily identify this one right it means when we run the test the test should run on this container and good news about this container is these are containers are intractable it means you can use these containers for the real interaction as well okay so just notice one more thing as soon as I run the test as of now can you see this is free this is also free the moment I run the test it make a request to the hub and it should occupy this okay can you see the within the container it is opening google.com learn automation and after five second it will good now let me do a small change let me change this to a chrome so this time it should run on three two seven six eight because three two seven six eight is for chrome three two seven six nine for Firefox now let me run this so this is actually selenium have a responsibility that based on your request it should take up the available one and you can see in this particular container the test execution started and it is running awesome right these are the two containers which is already running if you have multiple containers the test will start on these containers now what if I need to run these two tests parallely no problem at all you can use selenium sorry test energy to run the test battery so what we will do we will make a copy of it and this time I will say it's a chrome demo and for chrome demo I will check whether it has changed to Chrome or not yes it is changed so I need to run these two tests right so what I will do I will create a test in G dot XML file and I will say that we want to run tests in G docker so this test and you docker will simply run these two classes so what I will do I will make here PA our ratable earlier equal two classes okay so better we can keep it here because let's keep it test thread count equal to two it means I am going to run two threads parallely and this parallel should go in it test suite mode it means this is one test suite this is another test suite here I want to run chrome and here I need to run Firefox so when we say parallel to test it means it is talking about two different test suite thread count two equal to means we need to run two tests perrolli not just observe the behavior that these two containers will have the test battery so just right click on this XML file and see the magic okay something goes wrong it says line number 3 : number 51 okay maybe I have to give in double quotes let's run it again it says two tests - it cannot have the same name okay perfectly fine because here also I was giving test heroes it was test again so let me change it to different test suite and now run it again okay this is one kind these two containers and you can see the parallel execution Firefox is a little slow but as you can see the execution is happening happening parallel to both the containers and after five seconds the execution is getting stopped so this is the power of container this is a part of selenium grid where you just need to forward the request to the hub and how will decide where to run my test so if you run your test on how and if having any other node freely it will simply redirect okay thank you guys for watching this video so if you like this video please share with your friend and subscribe to this channel and if you have any query or doubt feel free to mail me so this is my email Mukesh or near the root alarm - automation comm and guys please share this channel with everybody who is into automation those who are looking for some new content and some great stuff I will be uploading many topics on test automation and once you're done with automation I will also start uploading on the dev ops and I will see you in the next video how would I say bye bye
Info
Channel: Mukesh otwani
Views: 67,131
Rating: undefined out of 5
Keywords: execute docker, selenium docker, parallel execution, Execute Selenium Test on Docker Container, Selenium, docker containers, selenium framework
Id: esb1v_d5-tM
Channel Id: undefined
Length: 10min 25sec (625 seconds)
Published: Wed Aug 28 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.