How to setup Selenium Grid 4 in Standalone mode | Run automation tests in parallel using grid

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back to maximum automation today in this video I'm going to show you how you can set up a selenium grid on your machine when we talk about setting up a selenium grid then we can set up the selenium Grid in three different modes the very first mode is Standalone then the second mode is Hub and node and the third one is dis distributed mode we can set up the selenium Grid in any of these modes based on our requirement today I'll start with the Standalone mode where we'll see what is Standalone mode and how we can set up the Grid in this mode also we'll see how we can run our scripts on the grid first of all let's talk about the Standalone mode Standalone mode combines all the components of the grid into one in this mode we only need a single machine to set up the grid it doesn't require any other machine in this mode we can set up the fully functional grid with a single command this is the easiest one among all three modes to set up the selenium grid when we set up the grid then by default the server will listen for web driver request on the The Local Host with port number 44 and also by default the server will detect the available drivers that it can use from the system path so we just need only a single machine and on that machine we can set up the grid using a single command and the same machine will be acting as Hub and node both so this is about this Standalone mode now let's see how we can set up the Grid in this mode first of all in setting up the selenium grid what we need is we need the selenium server jar file and to get the jar file what you can do is you can go to this selenium GitHub page and here you can go to the release section right now we have this release 4.8.0 and under this release you can look for the selenium server jar file so we have the option for a Char and Z file you can download any of them I have already downloaded the selenium server Char file once you click on it it will start downloading the file and once you are done with the download then you can move to the selenium server Char file right now I'm in one of my VM where I have kept that selenium server J file in a standalone mode we need only a single machine to set up the grid so either you can create the selenium grid on your local machine or any remote machine here I have this VM where I'll be setting up the selenium Grid in a standalone mode and I have this selenium server jar files available over here now to set up the grid what we need to do is is we need to open the command prompt here once the command prompt is open then we have to type the command as we discuss that a standalone mode provides a facility to set up the grid with a single command so we need to run only a single command and the command is Java hyphen jar selenium server jar file which we have downloaded did and after that type space stand alone and press enter in a while it will set up the Grid on this machine here you can see that it has detected four available processor because this VM has four processor so what it did it automatically detected the available browser drivers from the system path and added into to the Grid in this machine I have all these four browsers available I have Microsoft Edge Chrome Firefox and I as well and because this machine has four processors so it automatically added four instance of each browser whether it's Edge Chrome or Firefox for I it's added only a single instance because this browser is obsolete now when I say that it added four instance of a Chrome browser in the grid then it means we can run our scripts in four instances of a single browser at the same time suppose if I want to run my script on Chrome then I can run my scripts on four Chrome browsers at same time which will reduce my execution time now let me show you one more example I'm going to open a command prompt on my local machine also and then I'll set up the selenium Grid in Standalone mode so this is the command prompt on my local machine and let me type the command Java hyphen Zar selenium server jar file space Standalone so this command will set up this lenium grid on my local machine in Standalone mode here I'm setting up the Grid on my local machine to show you how it automatically creates the browser instances or how it automatically adds browser instances based on the system configuration so here you can see that it detected eight processor because this machine is built on eight processors and if I scroll it down then you can see see that here it discovered two browser drivers so on my local machine I don't have Firefox and I don't even have iie the only browser which I have on my local machine is Microsoft Edge and Google Chrome so you can see that it found that I have only two browsers available and it created or added the eight instances of each browser in the grid why eight instances because I have eight processor available in this machine while in this VM I had four processor available so it added the four instances of each browser so this is how it automatically creates the configuration of the grid now if I go to the browser and type Local Host with port number number 44 then you can see that this is the UI of selenium grid console here we can see that we have two types of browsers added to this grid and eight instances of each browser type is added which means that I can run my eight test cases in parallel on eight instances of a single browser type and if I run on both browser together then it means I can run 16 test cases parallely out of them eight can run on Chrome and other eight can run on edge So based on the configuration I can run my automation test if I don't want to do the cross browser testing then I can either run my test on Chrome browser or Microsoft Edge in that case I can only run a maximum of eight test cases in parallel now if I go to my VM and here also if I open the browser and navigate to the URL Local Host with Port number4 4 then you can see that here I have four browsers added as part of this grid and you can see that I have four instances of Chrome four instances of Firefox one instance of iie and four instances of Microsoft Edge added to this grid so this is how we can set up the selenium Grid in Standalone mode now if I talk about the benefit of setting up the selenium Grid in Standalone mode then one of the benefit is that I can use the grid for developing my automation scripts to test that whether the scripts which I have developed are working fine on selenium grid also the other benefit is sometimes when the scripts are failing over the selenium Grid in parallel execution then I can set up the Grid on my local machine to debug the fail test running multiple tests parallely saves a lot of time so whenever you are done with your automation development and you want to push your test cases to the repository but before pushing the code you want to test it so you can run your test in parallel on the grid to get the quick test results so this is how we can set up the selenium grid now let's see how we can run our automation scripts on this grid and for that let's move to the code here you can see that right now I have created the object of chrome driver and when we initialize the web driver object using Chrome driver then it will invoke the Chrome browser on the local machine and the execution will be done on the local machine browser now if I want to run my execution on a remote machine using selenium grid then what I need to do is first of all let me comment this code and then first I'll create Chrome options equal to new Chrome options after that I'll type driver equal to new remote web driver this is the method which we need to use to run our automation script on a remote machine this remote web driver method takes two parameters the first parameter is the URL of the selenium grid so let me provide the URL I can provide the URL like HTTP let's say if I want to run my script on crd which is running on my local machine then I can provide the URL as Local Host with port number 44 and after that in the second parameter I need to provide the Chrome options when we pass this chrome option then the remote web driver will get to know that it needs to run the test on Chrome browsers in Grid because we have multiple browsers available in selenium grid so to tell the driver that on which browser user we want to run our execution we have to pass the option object which can be a chrome option A Firefox option based on the browser type so that's what we need to do to run our test on the git now let's say if I run my test this search book test then the execution will be done through the selenium grid here if you can see on the command prompt that grid has received the request to execute the test and you can see the browser has been invoked and if I go to the selenium grid console then you can see that one session is running if I go to this session tab then we can see the session is running on Chrome with other session details like this is the node where the session is running now you can see that there are no running session at the moment because the execution has been completed and if I go back then you can see our execution is done similarly if you want to run your test on a grid hosted on a remote VM then what you can do you can provide the remote machine URL here instead of Local Host so I'm adding the IP address of the remote machine and now this will run the test on the VM where selenium grid is running now you can see that we have received one session request on this VM and the execution has been started on Chrome browser and if I go to selenium grid console then we can see that we have one session started on this machine so this is how we can run our automation script on a selenium grid and now let's say if I want to run multiple tests at the same time so far I have executed only a single test on the grid but let's say if I I want to run multiple tests here I'm going to run all the tests available under home test in parallel mode when I run it we'll see that all tests will start running together at the same time and now if I go to this remote machine then you can see three Chrome driver instances started successfully and if I go to this session tab then we can see four sessions are running currently here you can see that the maximum session supported is four and maximum session is running is also four now it is moved to one and now it moved to zero because the execution is completed so this is how you can execute your test us using selenium Grid in Standalone mode that's it for today I hope you like this video in case of any query please put your comments in the comment box also please don't forget to like share and subscribe to the channel thank you
Info
Channel: Maximum Automation
Views: 10,258
Rating: undefined out of 5
Keywords: selenium grid tutorial, selenium grid setup, selenium grid overview, what are the advantages of selenium grid, what is selenium grid, how selenium grid works, selenium grid hub and node, selenium grid parallel execution, selenium grid cross browser testing, cross platform testing, beginner, step by step, when to use grid, grid architecture, grid components, how to setup selenium grid 4, selenium grid 4 tutorial, what is, standalone mode, selenium server jar file, grid modes
Id: b9s5bhoXlyo
Channel Id: undefined
Length: 16min 32sec (992 seconds)
Published: Tue Feb 07 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.