Skip to main content
Skip to footer
Search
Connect
Watch fullscreen
Like
Comments
Bookmark
Share
Add to Playlist
Report
02_Setup & Configure WebDriver
Automate with Meer
Follow
7/7/2024
Category
📚
Learning
Transcript
Display full video transcript
00:00
Hi everyone, in this video we are going to see how to set up and configure Selenium WebDriver
00:06
and also we will see how to write the first Selenium script. So let's get started and
00:13
how Selenium WebDriver works. Let's say for example we have a browser.
00:19
And we perform some user actions on this browser and we wanted to automate these actions and that
00:25
can be done using Selenium WebDriver. And we discussed what's a WebDriver in the
00:32
introduction section. So WebDriver is a set of libraries. Using these set of libraries
00:39
WebDriver is going to communicate with the browser, right? And how are we going to use
00:45
this WebDriver, you know, to write the automation scripts. So for that we can have
00:52
any ID of our choice. ID is integrated development environment. So it's a code editor like Eclipse,
00:59
NetBeans, IntelliJ, any editor, right? Code editor you can choose and we write the script using this
01:06
code editor. And how do we write the code is WebDriver has said it's a set of libraries.
01:12
Meaning library is a collection of, you know, jar files and each jar is in turn a collection
01:18
of packages and classes, right? So using the again the classes will have methods, right? So
01:25
using these classes and methods of, you know, this WebDriver. So this has methods and classes
01:33
and we'll use this class and methods and write the automation script in using this IDs, right? And
01:41
WebDriver knows anyway knows how to communicate with the browser. So this is how we are going to
01:47
write the script and this is how WebDriver will communicate with the browser. And this is how,
01:52
you know, WebDriver works. WebDriver is called as API application programming interface as it
01:58
acts as the interface between our, you know, our code editor and the browser, right?
02:04
Now, as a first step, what we'll do is WebDriver is an open source. Selenium is an open source,
02:10
right? So we are going to download this WebDriver and as a second step, we'll open any ID of our
02:18
choice. And then we'll configure. We'll see how to configure this WebDriver in our ID,
02:24
followed by a first script we are going to write using Selenium. All right, so
02:30
just type Selenium.dev you'll be navigated to the official website of Selenium. So this is the
02:41
official website of Selenium. You can see the components, three components which we discussed,
02:45
right? These are the three components Selenium WebDriver, ID and
02:52
Selenium. So you can see downloads here. Just click on this downloads,
02:57
click on this downloads, slowly scroll down. You will see the WebDriver language bindings, right?
03:02
So these are the programming languages supported by Selenium. You can find Java here and you see
03:07
a stable here, right? So a link here always you'll have a latest stable version for download here.
03:15
So don't bother about this version. Just go ahead and click on this link and always download the
03:20
latest stable version. Now see a zip file is started getting downloaded, right? So
03:27
fully and once the download is done, right? So you will see something like this, the zip file, right?
03:36
This zip file. So just ignore all the other files. Just see this file. So this is how you'll
03:42
get a zip file in your case. And it's always a practice to actually create a folder, maybe in
03:49
any drive. I created it in my C drive. So with the name drivers and copy this zip file here and
03:56
then extract it. Right click extract all. I already extracted this file. You can see that here.
04:01
Just open this. Once the extraction is done, you can see number of jobs.
04:05
I'll click on create a Java project as that will be the first step, right?
04:10
I created a project. I'm going to create a package. I'll name my package as something like com.sample
04:24
and then we'll start creating the class. Okay, let's create a class. I'll name my classes
04:32
first Selenium script.
04:40
Alright, first step. What we'll do is we'll actually add the web driver to our project.
04:45
And how do we do that? Right click on the project, go to properties, click on Java build path.
04:51
You'll see the number of tabs here, right? So click on libraries. Click on the add external
04:59
jars and you can see here, right? I'll navigate to the web driver folder where you extracted it.
05:07
So you can see all the jar files here, right? So just do control A and then click on open.
05:19
So all files got added. Go back and select all meaning do again control A.
05:26
Exclude lib directory as we already added the files under it.
05:31
And click on open again. So all the jar files got added to the project. Now just click on apply and close.
05:37
So we have the libraries which come with the web driver. We added them to our project now.
05:43
Alright, now we are ready to write our first automation script. So I created a class.
05:48
So I have a main method in it and I'm going to write the first automation script now for that.
05:54
The first step would be system.setproperty.
06:03
So system is a class and set property is a method which actually takes two parameters key
06:09
and a value pair. So a key and a value pair. So key will be webdriver.chrome. I'm going to use
06:17
browser as Chrome here. So webdriver.chrome.driver and value will be the executable for the browser,
06:26
right? And how do we get the executable? So what's the executable first of all so
06:31
executable of a browser is so webdriver needs to launch the browser, right?
06:37
So to do any user action it needs to launch the browser and how do it launch so it needs
06:43
the executable. So we need to download the executable and for that we'll again go back
06:48
to the official documentation of Selenium and slowly scroll down here. You will find
06:54
something called browser. So click on that here. You see all the supported browsers by Selenium.
07:00
So as we wanted to, you know, automate the script for Google Chrome. So just click on
07:05
Chrome documentation.
07:11
You will see all versions available in downloads and latest beta release latest table release
07:15
as well, right? So how do we download or which file to download for that? We need to know which
07:23
Chrome version we are using how to find Chrome version is you see three dots on the top right
07:29
corner, right? So click on that go to help about Google Chrome. You will see the version of your
07:35
Google Chrome. So the first two numbers are the first number which comes before the dot, right?
07:42
So that's called major version and whatever is after that is called as minor version. So you
07:47
don't need to bother about this minor version at least before the dot should be considered
07:55
till here, right? This is my Google Chrome version so that we need to find it out here.
08:04
So if you don't find that here as a latest table release, so you will actually click on
08:09
this downloads and find the correct executable Chrome driver executable, right? So here in my
08:16
case, it actually matched with the major and minor version till the this dot, right? So
08:23
just click on this. And again, you will see a list of files here for each operating system, right?
08:30
And I wanted to download this Chrome driver executable for my Windows operating system. So
08:36
I'm going to click on this zip file so you can see the zip starts getting downloaded, right?
08:42
So in my case, it I already downloaded. I just cancel it. So in your case, you'll just proceed
08:46
and allow the download to complete fully. And then you can see here as I have many folders.
08:55
So I just created another folder with my Chrome version and copied my zip file here.
09:01
So this is Chrome driver executable, right? Let me extract this.
09:10
And open this folder you see an executable here, right? This is the Chrome driver executable
09:15
and this we need to provide it in the system dot set property value. So we need to provide
09:22
the full path and how do we get the full path? If so, just hold hold on shift key and right click
09:29
you will get an option as copy as path. And remember you need to hold on shift key. Otherwise
09:34
you will not get this option. I'll show you see I didn't hold the shift key so you'll not find
09:39
this copy as path now. So only if you press if you hold down shift key and right click only
09:45
then you will find this copy as path. Just remember that and click on this copy as path.
09:52
Go back copy this path you will get a extra slash here extra quote. Just remove that
10:00
at the beginning and end. So what did we do here? We wanted to let the web driver or the let
10:08
the program know where the browser executable is present so that we actually specify in the value
10:16
and the key will be the driver. So driver variable web driver dot Chrome dot driver. So this will
10:23
be assigned the executable so that the program knows how to or the web driver knows from where
10:30
to actually pick up the executable and launch the browser. So that will be the first step in the
10:36
while writing the automation script. And this browser can be any browser supported by Selenium.
10:43
We have just chosen Google Chrome as an example here, right? So the second step will be or the
10:50
second line of code. It would be web driver. We'll be creating a object of web driver interface
10:58
and will instantiate it to the Google Chrome. Right Chrome driver.
11:07
So Chrome driver is a class here which is actually implementing the web driver interface.
11:12
So we discussed web driver is an interface, right? So Chrome driver is a class which is
11:16
implementing the web driver interface here. So we are getting error. As we need to import this
11:23
web driver interface into our project, right? So import web driver from org.openqa.selenium.
11:30
Just click on this. So it gets, you know, imported from this package. Same goes for
11:37
the Chrome driver class as well. So import it from org.openqa.selenium.chrome. This is
11:42
the package where this Chrome driver class is present. That's all we are done with, you know,
11:51
writing the first automation script, right? So right click. Run as Java application.
12:00
So it should launch the Chrome browser. See it launched the Chrome browser and you can see
12:06
a note also here. Chrome is being controlled by automated test software.
12:09
This is coming from the Google.
Selenium Tutorials
12:11
|
Up next
02_Setup & Configure WebDriver
Automate with Meer
7/7/2024
4:54
01_ Introduction to Selenium
Automate with Meer
7/1/2024
Recommended
0:28
Append Tables
Automate with Meer
7/19/2024
13:18
02_MachineLearningTermonology
Automate with Meer
7/16/2024
1:00
Its Beautiful day
Automate with Meer
7/10/2024
1:22
FeatureJourny
Automate with Meer
7/10/2024
0:20
True To Some Extent
Automate with Meer
7/8/2024
0:13
Two for the price of 1
Automate with Meer
7/6/2024
0:27
Date & Time Truncate
Automate with Meer
7/6/2024
3:11
Cap_OutofPlastic
Automate with Meer
7/2/2024
0:33
Auto Apply Borders
Automate with Meer
7/2/2024
11:45
01_Introduction to Machine Learning
Automate with Meer
7/2/2024
1:34
Company Logo ExcelTips
Automate with Meer
7/1/2024
0:31
Did You Know-Bees
Automate with Meer
7/1/2024
0:32
BackGround
Automate with Meer
6/30/2024
0:19
AI Featured Vision
Automate with Meer
6/30/2024
0:43
A huge upset! Argentina vs Saudi Arabia
Automate with Meer
6/30/2024
0:28
Append Tables
Automate with Meer
7/4/2024
0:51
Former Aide Claims She Was Asked to Make a ‘Hit List’ For Trump
Veuer
9/27/2023
1:08
Musk’s X Is ‘the Platform With the Largest Ratio of Misinformation or Disinformation’ Amongst All Social Media Platforms
Veuer
9/27/2023
4:50
59 companies that are changing the world: From Tesla to Chobani
Fortune
9/27/2023
0:46
3 Things to Know About Coco Gauff's Parents
People
9/23/2023
0:35
8 Things to Do in the Morning to Improve Productivity
Martha Stewart Living
9/22/2023
2:11
Why You Should Remember Aretha Franklin
Goalcast
9/23/2023
1:18
USC vs. Colorado: Can Caleb Williams Earn a New Heisman Moment?
SportsGrid
9/26/2023
1:04
Vic Mensa Reveals Celebrity Crush, Biggest Dating Pet Peeve & More on Speed Dating | Billboard News
Billboard
9/25/2023
1:09
Hollywood Writers Reach ‘Tentative Agreement’ With Studios After 146 Day Strike
Veuer
9/25/2023
1:26
Love is Blind stars admit they're burnt out from social media
Fortune
9/25/2023
2:01
NHA Customers in Limbo as Company Faces Potential Merger
SportsGrid
9/25/2023
2:55
Vanilla Ice Explains How the 90’s Shaped America
FACTZ
9/24/2023
1:26
Hot 100 Chart Reveal: Sept. 30, 2023 | Billboard News
Billboard
9/25/2023