Firefox Browser Automation | How To Run Selenium Tests In Firefox

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome back to our Channel in today's tutorial I'll be talking about how we can automate or how we can run selenium tests on Firefox browser okay uh if I go back to my playlist here you can see this is our early video here we saw how we can automate the Microsoft edge browser if you have not watched this video I suggest you to go and watch this video how you can automate the edge browser okay I will keep the link in the I button and also in the description you can go and have a look at that in today's video I will show you how we can automate the Firefox browser okay before starting this video I would like you to please like and share our videos if you like our videos really and also at the same time if you really like our videos please please please subscribe to our Channel and hit the Bell icon so that you receive notifications regarding our latest updates thank you and at the same time I want to thank all of you who have been supporting us for such a long time thanks a lot so let's get started I have Firefox installed in my system if you guys don't have it installed you can just go to any browser and search for Firefox and simply install it okay and also there is one very important catch here whenever you are trying to automate the Firefox browser that means whenever you are trying to run selenium tests on your Firefox browser then you should also be knowing the version of your Firefox okay so for that what you need to do you just go to this three dots and go to help and click on about Firefox it will show you that current version okay so if you see here the Firefox version for me is 107.0.1 this is the latest version please remember whenever we are trying to automate the Firefox browser or any browser we should have that particular driver in our project because we need to tell selenium about the path of our driver that particular browser's driver okay so for this we need the geeko driver in order to automate the Firefox browser we need the giko driver as I have told you earlier we have different drivers for different browsers okay so as you can see if I go back to my project for the edge browser we have the edge driver here you can see and this is my Edge driver inside my project for the Chrome browser automation we need the chromedriver.exe okay these are executable files so similarly for the Firefox browser the browser driver is called gecko driver Okay so let me just create one new Java class here so Firefox browser automation and keeping the class name relevant to the operation or the program that you're going to write okay so first let me create the static web driver instance if you don't know why I am doing this you can just go back to the earlier videos of this playlist and refer them and then you can come back here okay we create static web driver because we can call it directly without creating any object of this class okay so now I will have the main method let me just delete this extra space here so first thing first we need to tell selenium about the location of our glyco driver but right now you can see we don't have the Graco driver in our project what I will do I will just show you the steps how you can get the Eco driver just go to your browser this is my Google Chrome here I will just simply write Kiko driver download and you can just go to the first link here and you can see the latest version is 0.32.0 okay so if you just go and see properly here this version of the web driver will support all versions after 106 okay so that means as I showed you here in my Firefox the version was 107 right you can see here 107.0.1 so the Firefox driver or the geeko driver that I have here this latest version will be sufficient to automate the Firefox browser so I'm going to download and install this I'm just going to show you the steps I have already downloaded it I'll just scroll down and what you guys need to do is you have to just download this 32-bit zip file okay just click on this and it will get downloaded and I have already done that and after downloading this ZIP file you have to extract that file please remember that okay and then you have to show that file into your project so let me minimize this let me go to my desktop here I already have it saved here you can see I have this folder gecko driver inside that I have the ecodriver.exe so I'll just copy this here and go back to my project and paste it in my drivers folder okay just paste it here okay so right now I have the geeko driver here in my project why I am suggesting you people to store it in your project the reason is if at all you are taking this project to any other systems or giving it project to any other friend of yours or any colleague of yours then all the dependencies all the drivers everything should be inside the same project otherwise if you put it in another file in your system and try to locate it then while sharing the project with someone else you might not have that thing so this will make all your test cases fail that should not happen right so in that case you should always have all your dependencies inside your project so that whenever you are giving the path to that file or that dependency the jbm is able to find that particular location okay so that is why we do that now as we have done for the other cases we first have to tell selenium about where our giko driver is located so system dot set property it takes two arguments the first one is by default the name of the driver so for Firefox it is web driver dot gecko dot driver okay and the second argument that it takes is the location so for the location as I have done previously I will tell you again first we have to write Dot and forward slash that means the current project inside that we go to our drivers folder and inside that we type the name of the driver so it is gigo driver dot exe okay you have to give the proper extension that's very important please mind it now we can instantiate our web driver so I can simply say driver is equal to new as we are automating the Firefox browser we have to instantiate the web driver to Firefox Drive that's it we have done that so let me also do some other stuff so let me just simply maximize the screen so driver Dot manage.window.maximize so that we can view the whole maximize screen after that we can just use the driver instance to go to a particular URL so driver.gift here I can pass a URL suppose we are trying to automate the selenium dot Dev website okay so http colon double forward slash www dot selenium dot Dev and forward Flash okay so I need you to see whether it is able to open the Firefox browser or not okay so for that I'll just use some pause so for that what I am going to use is the set Dot sleep command and let us wait for three seconds so it will be three thousand milliseconds and as we already know we have to add an exception to the method signature or you can also use a try catch block doesn't matter both will work the same way I am just adding an exception so it will be adding it through declaration here fine after that after waiting for three seconds we will just quit the current instance of the browser okay driver so that's it but suppose you also want to get the title and the URL of that particular page so what we can do we already know that the title and the URL of any web page are text that means we have to call the string class title is equal to we use the web driver instance dot get title method and again for the URL I will use URL is equal to driver dot get guarantee one okay so we have our two methods of the driver instance which will help us to get the title and the URL now suppose I want to display it onto the console or our terminal I will simply say s out title plus I will just concatenate my title variable similarly for the URL I will just contact my URL variable okay so this is a simple string concatenations it will store the title and the URL okay so this is it we are automating the selenium.eb website and we're waiting for uh duration of three seconds guys this is hard weight I am not recommending you to do it in your proper projects just because I want to see the automation happening I am doing this but this Hardware is not recommended for proper projects okay so after that I am restoring the title and the URL in different variables and then printing them onto the terminal okay then finally I am quitting the browser so let me run this and see what happens it should open the Firefox browser yes it's doing that this opening selenium.net waiting for three seconds and then it should quit yes you can see and into our terminal or console you can see we have the title of the webpage which is selenium and we also have the URL that we have first ectps www.savingm.dev so our program is working fine you can see this is the entire program okay so we have automated the Firefox browser successfully and suppose if you want to see the stuff let me just comment the quit method and run it again okay I'm running it again so it's opening Firefox maximizing the window opening selenium dot Dev and then after three seconds it is not quitting the browser because this time what we have done is we have commented the quit method of the Webdriver so if I open the Firefox again you see here okay the title is selenium and the current URL is synonym okay so it's successfully automated because you can see there is a robot symbol here in the Firefox search bar okay so it is successfully doing it right so let me just uncomment this and let me run this again so it is opening Firebox and then it is opening the selenium URL and then after three seconds it should quit the browser and on to the console we have the title and the URL okay so everything is working fine this is how you automate the Firefox browser and please remember the browser driver for firefox's geeko driver so we have to have the key code driver with us and I have kept it in my project because whenever I want to transfer this files to any other system I get all the dependencies along with my project to the other system okay so this is the benefit so guys this is it this is about this video I hope you have liked it and at the same time if you have any doubts you can post them in the comment section I'll be very happy to clarify all those and if you really like this video please don't forget to share with friends and family and at the same time please don't forget to like And subscribe to our Channel and also hit the Bell icon so that you receive notifications regarding our latest updates so that's it guys thank you I am sort of signing off today see you in the next tutorial bye
Info
Channel: Coders Arcade
Views: 4,783
Rating: undefined out of 5
Keywords: selenium webdriver, selenium firefox, selenium firefox driver, run selenium test on firefox browser using java, geckodriver selenium, geckodriver.exe download, what is geckodriver, gecko driver firefox, selenium testing tutorial, selenium java tutorial, launch browser, selenium webdriver tutorial, selenium webdriver tutorial for beginners, selenium with java, selenium online training, how to launch firefox browser using selenium webdriver, locators in selenium, selenium
Id: q-pptnk12iA
Channel Id: undefined
Length: 13min 41sec (821 seconds)
Published: Thu Dec 01 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.