Hello everyone, in this video session, I am going to explain Part Six of selenium four that is taking screenshots of a page in Firefox browser using get full page screenshot as method. In Selenium four a new method has been introduced that is get full page screen shot ass method, okay. And this method works only in Firefox browser. And what is the purpose of this get full page screenshot as method. So it will take the screenshot of the web page. in Firefox browser, there's a purpose let me practically demonstrate how to use They get full page screenshot as method to take the screenshot of a webpage in Firefox browser.
Okay, let me practically demonstrate an eclipse ID and as you can see here there is a Maven project which is actually configured with which is already configured with Selenium for and other required stuff. Okay. So to see how to create a Maven project and how to configure that with the Selenium four and other stuff required just go to the first video of this Selenium four video series and come back here guys hoping that you have created this man project and configured that with this Selenium for another request of let's create a new class here, new class and name this class as something like demo six. Select this public static void Main so that will be automatically added inside In this main method, write down some generic or common stuff that we generally write even in Selenium three, like WebDriver manager dot chrome driver here this time it's not chrome driver guess we have to use this method in Firefox browser so Firefox driver got set up here to say then driver driver is equal to new Firefox driver that's it.
Import this web driver interface and Firefox driver class then maximize the browser window using this and then implicit wage labor dot manage dot timeout dot implicitly wage time unit God seconds. Okay, that's it. Now we need to open this application URL and take a screenshot of it. Okay, so this is the application URL that you have to take the screenshot of it, let's say college application URL that you want to open and paste into this driver dot gate here. And once this is open, this is a process for opening whatever I'm going to explain now is a process for taking the screenshot of the webpage in Firefox browser, and I'm going to use this method known as get full page screenshot as method okay. So let me show you the fact that we have to cast the driver gaze with Firefox driver class.
Okay, we have to cancel the driver of this, this driver with this Firefox driver class and surround that with circular brackets and then said dot get full page screenshot as method okay it's not get screenshot as its full page screenshot as method guys and you have to type out put type dot file here and and when you do that you will get this extra thing this remove this x with surrounded with less than and greater than symbols. Now for the most here, it will return you the file file some SRC file is equal to Okay, the screenshot taken by this method of the in this five of this particular application in this browser known as Firefox browser, okay will be saved into this SRC file, import this file from java.io. Now, we need to copy this source file, the screenshot which is stored in this source file into a required folder on this project.
You can create folder anywhere in this project, okay? And the better way is to create this under the title Target folder here, right click on the target and say folder. give any folder name as screenshots. And say finish, we have created a screenshots folder under the target. Now we have to copy the screenshots stored into this SRC file into the screenshots folder, okay? So for that we have to use something known as file utils dot copy file, okay you have to select this sometimes you may get some error related to you will not be able to import this file utils guys, okay, in my case I'm able to import I am able to get the import statement here as you can see, or Apache Commons IO dot file utils okay if I don't have this will get this right.
In some cases guys, okay you will not get this import statement Okay, you will not get an option to import this file utils in that case just For this dependency tax of this common silo, you can find this common silo dependency tax in mbn repo so you can get from there, Apache Commons, iOS, and whatever the latest version, you can put it here. And once you build it, you will get this import statement. In my case, I'm automatically getting that's fine. And here, we have to put this SRC file here, the place where the screenshot of this page has been stored. Okay, from here I want to copy this screenshot stored in this SRC file into some destination. That is this screenshots folder.
So, for that, we have to simply say, new file off. file off the project location is like dot okay dot stands for this project, then slash. Under this project we have this target folder directly. Okay, you see, the target folder is directly under this project. So target folder target Under the target folder, we have the screenshots slash screenshots folder, under the screenshots folder I want to create a file. Okay screenshot file name I want to view Okay, whatever the screenshot that is stored here, we have to save it a file name under this screenshots folder.
I have to give some name here so web page okay web page screen otherwise web page dot png I will say okay the page Firefox the screenshot has been taken in the Firefox browser so I'm saying web page Firefox dot png okay is the screenshot name have given and the extension is dot png guys. Now this or the most on this and say add throws declaration to resolve the era. One the screenshot has been taken in this Firefox browser. This particular application and saved into this SRC file. Using this step, we have copied the screenshot stored here into the new location. That is screenshots folder with the name web page Firefox dot png.
Okay, once the screenshot has been taken and stored here, let's close the browser window. So that's it. Let's run this code. So the Firefox browser should launch. Yeah, Firefox browser got launched. We'll open the application URL and immediately take a screenshot and then close the browser.
Okay. So now reference the screenshots folder here. And as you can see here, the web page Firefox dot png, okay, so this is the screenshot of the page that has been taken by this get full page screenshot as method okay this will only work in the Firefox browser. Okay. So so that's it guys in the next video session I am going to explain the other new feature of selenium for that is this Get rekt method okay which is recently which is like the newly introduced in Selenium for get right method is newly introduced in Selenium for and which it is and it is used for retrieving the height weight assigned by columns coordinates of a UI element. So, I will explain in detail about this get Rector method of selenium four in the next video session.
So, that's it guys. See you in the next video session. Thank you Bye