Session 21 – Selenium with Java | Introduction & Enviro… — Transcript

Introduction to Selenium WebDriver with Java, covering its architecture, components, and environment setup for automation testing.

Key Takeaways

  • Selenium WebDriver is a Java interface central to web automation.
  • Browser-specific driver classes extend RemoteWebDriver to handle unique browser architectures.
  • WebDriver interface cannot be instantiated directly but can hold references to driver objects.
  • Understanding WebDriver’s architecture helps in writing effective cross-browser automation scripts.
  • Selenium suite includes IDE, WebDriver, and Grid for comprehensive testing solutions.

Summary

  • Selenium WebDriver is a key component of the Selenium suite used for automating web applications.
  • WebDriver is designed as a Java interface implemented by multiple classes like ChromeDriver, FirefoxDriver, and EdgeDriver.
  • RemoteWebDriver is a parent class that implements the WebDriver interface and is extended by browser-specific driver classes.
  • Different browsers require different driver classes due to their unique internal architectures.
  • WebDriver methods may not work universally across all browsers, necessitating specific implementations.
  • The Selenium suite consists of Selenium IDE, Selenium WebDriver, and Selenium Grid.
  • WebDriver allows testers to automate browser interactions through sending URLs and performing operations like insertion, update, and deletion.
  • The video explains the layered architecture of web applications: front end, business logic, and database layers.
  • An API (Application Programming Interface) is introduced as a concept to understand WebDriver's role.
  • The session includes environment setup and writing a basic automation test case using Selenium WebDriver.

Full Transcript — Download SRT & Markdown

00:03
Speaker A
So from today, we are going to start Selenium WebDriver. First, let us see the introduction, like what is Selenium WebDriver and what it contains. Then we will see how we can set up the environment, and after that, we'll see how we can write a basic automation test case.
00:22
Speaker A
how we can write a basic automation uh test case Okay so first thing uh what is selenium selenium web driver there are three definitions are there so we need to understand those three definitions first so what is selenium web driver the first definition is web driver is one of the
00:44
Speaker A
Okay, so first thing, what is Selenium WebDriver? There are three definitions, so we need to understand those three definitions first.
01:01
Speaker A
selenium through which we can automate web applications okay this is a main component for automating the web applications and the second one is web driver is a Java interface web driver is a Java interface so in Java we have understood about interface like what is
01:20
Speaker A
What is Selenium WebDriver? The first definition is WebDriver is one of the components in Selenium. WebDriver is one of the components in Selenium.
01:39
Speaker A
there must be a class which will implement the interface so these are all the points we have understood so the celum web driver is an interface they have designed web driver as an interface initially and the later on the web driver interface implemented by using multiple
01:54
Speaker A
Selenium contains three components: one is Selenium IDE, Selenium WebDriver, and Selenium Grid. These are the three components which we can call as a Selenium suite, and WebDriver is one of the components in Selenium through which we can automate web applications.
02:12
Speaker A
web driver is an interface and whatever interface which you have if you want to implement this web driver for example Chrome browser is there so as an tester I'm using Chrome browser so whatever methods are there in the web driver interface if you implement those
02:27
Speaker A
Okay, this is the main component for automating web applications. The second one is WebDriver is a Java interface. WebDriver is a Java interface. So in Java, we have understood about interfaces, like what is an interface in Java.
02:44
Speaker A
architecture level there are differences so same web driver methods may not work for all kinds of browsers so they have created different classes for each browser for example if it's is a Chrome browser they created something called Chrome driver class and this class
03:01
Speaker A
An interface is a blueprint of a class which contains public and static variables and contains default methods, public methods, abstract methods. If there is an interface, that should be implemented by using a class, right? There should be some class which will implement the interface.
03:24
Speaker A
there are Edge driver is also there and Etc so how many browsers are the market there are number of classes are implemented web driver interface and again web driver interface is not directly implemented by these classes but in between there is another class called remote web driver class
03:46
Speaker A
So these are all the points we have understood. So the Selenium WebDriver is an interface. They have designed WebDriver as an interface initially, and later on, the WebDriver interface is implemented by using multiple classes like ChromeDriver class or Internet Explorer class, Firefox browser class.
04:07
Speaker A
an interface and remote web driver is a class and rest of them all classes clone driver Firefox Ed driver so these are all extended classes from reboard web driver so this is how exactly they have designed web driver is a Java interface which contains some variabl some static method
04:27
Speaker A
Because when I say, when I talk about web application, people can access web applications in different browsers. Some people will use Chrome, some of them will use Firefox, and some other browsers. So WebDriver is an interface, and whatever interface you have, if you want to implement this WebDriver, for example, Chrome browser is there.
04:48
Speaker A
in other words we can say these are all CHS of web driver also okay so this is a architecture so web driver is a Java interface that is a second def yeah remote web driver is a parent of all three
05:04
Speaker A
So as a tester, I'm using Chrome browser. So whatever methods are there in the WebDriver interface, if you implement those methods by using ChromeDriver class, these implementations work only for Chrome browser. It cannot be used for any other browser because the browser's internal architecture will be different.
05:24
Speaker A
if I create an object for these classes can we hold those objects in the web driver variable can we create a variable object for web driver object we cannot create but the variable we can create right so web driver variable also can hold all the objects of this classes okay remember this point
05:44
Speaker A
Even though the purpose or goal of the browser is the same, internally, at the implementation architecture level, there are differences. So the same WebDriver methods may not work for all kinds of browsers. So they have created different classes for each browser.
06:07
Speaker A
and how it is going to work and then we will understand why web driver is an API okay so let us try to understand what is an API a simple definition I'll give you application programming is interface and three uh words are there in this application programming and interface
06:29
Speaker A
For example, if it is a Chrome browser, they created something called ChromeDriver class, and this class implements all the methods from the WebDriver interface. Similarly, there is another class called FirefoxDriver class, and this class also implements the same WebDriver interface according to Firefox browser architecture.
07:00
Speaker A
any web application there are three kinds of layers are there okay one is called front end layer let's say this is our front end and the second one is called application layer or business logic layer and the third layer is DB layer or back end layer okay
07:28
Speaker A
So like this, how many browsers are in the market? Like this, there are EdgeDriver also, and etc. So how many browsers are in the market? There are a number of classes implemented WebDriver interface, and again, WebDriver interface is not directly implemented by these classes, but in between, there is another class called RemoteWebDriver class.
07:47
Speaker A
interact with the application through browser right we will always browse web pages through browser only all web applications so through the URL so what we will do here we will send some URL right and we do some operations here insertion updation deletion so whatever thing
08:03
Speaker A
RemoteWebDriver class. So actually, WebDriver interface is implemented directly by RemoteWebDriver class, and this RemoteWebDriver class is extended again into ChromeDriver, FirefoxDriver, EdgeDriver. So these are the extended classes from RemoteWebDriver class.
08:21
Speaker A
I have not installed anything on my local system just browsing the pages but actually from where those pages are coming from from the database yeah actual data is stored in the database so this is hold the data okay and between these two there is another layer called business logic layer or which
08:41
Speaker A
Okay, WebDriver is an interface, and RemoteWebDriver is a class, and the rest of them, all classes like ChromeDriver, FirefoxDriver, EdgeDriver, these are all extended classes from RemoteWebDriver. So this is how exactly they have designed. WebDriver is a Java interface which contains some variables, some static methods, public methods, abstract methods, and so on.
08:59
Speaker A
will be there in inside this the programmers or developers whatever the code they have developed and the actual functional code actual software will be installed in this particular layer so what exactly happening is whenever you're sending some request because whenever hit the URL or when
09:17
Speaker A
And again, the WebDriver interface is implemented by RemoteWebDriver class, one single class, and this again RemoteWebDriver class extends into ChromeDriver, FirefoxDriver, and EdgeDriver. Now these three are the child classes of RemoteWebDriver class.
09:35
Speaker A
application programming interface it's a kind of a a program we can simply see it's a kind of a program a logic okay and there are n number of apas will be resides in this business logic okay n number of apas so many apas and whenever you send some request and again there are different type
09:56
Speaker A
In other words, we can say these are all children of WebDriver also. Okay, so this is the architecture. So WebDriver is a Java interface. That is the second definition.
10:14
Speaker A
API will be triggered and what is an API API is a small piece of code which is a simple program and this API interface will get the request and whenever we send a request particular API will be triggered and what that API will do as soon as it receive the request and it will also send the same
10:36
Speaker A
Yeah, RemoteWebDriver is a parent of all three classes, and we can also consider WebDriver is also parent of parent. Suppose if I create an object for ChromeDriver or Firefox or EdgeDriver, can we hold that object in the RemoteWebDriver class? Yes or no? Can we hold that object in the RemoteWebDriver class object? Yes.
10:55
Speaker A
will go given back to the API and that means it is called response and once API get the response the same response will be presented to the user in understandable format so that is how the API works so whenever you take any kind of API that requires some kind of a request that means we
11:17
Speaker A
Similarly, if I create an object for these classes, can we hold those objects in the WebDriver variable? Can we create a variable object for WebDriver object? We cannot create, but the variable we can create, right? So WebDriver variable also can hold all the objects of these classes.
11:40
Speaker A
the AP if you go to the restaurant okay let's say there is a kitchen actual food will be prepared in the kitchen right so here the food will be prepared and here the customers are waiting let's say these are the customers customers directly don't go to the kitchen and get the food right
12:00
Speaker A
Okay, remember this point. This is the most important point. Right? Next one, WebDriver is an API, application programming interface. This is the third definition. WebDriver is an API.
12:11
Speaker A
and serve here so this person is called API it is doing he is actually doing the job of API okay so this is how we can understand so microservice is totally different so that will not come here I'm
12:25
Speaker A
So to understand this, we need to first understand what is an API, okay, and application programming interface, what exactly the API means and how it is going to work, and then we will understand why WebDriver is an API.
12:48
Speaker A
exactly API means so API is an interface now you try to understand these terms application programming and interface APA contains what AP contains what a business Logic the business logic is written in the programming language so this is basically having some programming application
13:10
Speaker A
Okay, so let us try to understand what is an API. A simple definition I'll give you: application programming interface. And three words are there in this: application, programming, and interface.
13:28
Speaker A
the request to the API and API providing the response so it is also acting as an applic to assisting the application actually so this is an application so API is a application because it is assisting to the application so it is an application which contains a programming so it is
13:45
Speaker A
We need to divide these three terms and then we need to understand application, programming, and interface. Okay, these are three terms we need to understand. So let me explain what exactly it is. Just a moment.
14:04
Speaker A
you understand in detail so I will share some of the videos introduction videos of API you can just watch them and try to understand for now this much is more than enough okay so now we have understood what is an API but we need to understand why web driver is API why web driver is an API so let's
14:26
Speaker A
Yeah, so application programming interface. So normally, if you take any web application, there are three kinds of layers, okay? One is called front-end layer. Let's say this is our front end, and the second one is called application layer or business logic layer, and the third layer is DB layer or back-end layer.
14:51
Speaker A
here so all web driver methods will be here and web driver will interact with the browser okay so how this web driver methods will will invoke let's say web driver means what interface which contains different type of methods again these are all implemented implemented by remote web driver
15:11
Speaker A
Okay, front end, application server, or we can say web server or web layer, and database. So these are the three parts that are there if you take any web-based applications.
15:28
Speaker A
own purpose who will call this method from the web driver our Java program our from java code or in Eclipse whatever ID we are using from that ID eclipse or intellig so whatever ID you are using from here through Java some Java programming or python or whatever through Java program we are
15:51
Speaker A
Okay, so what is front end application means? This is also called presentation layer because the user will directly interact with the application through the browser, right? We will always browse web pages through the browser only, all web applications.
16:10
Speaker A
okay button so all kinds of actions on the browser will be done by using the web driver methods web driver methods will do the job okay and we will we will call these web driver methods is through Java program Java is a client we can observe the Java is a present presentation okay Java will call
16:32
Speaker A
So through the URL, what we will do here, we will send some URL, right? And we do some operations here: insertion, updation, deletion. So whatever thing you are doing on the browser level, that all comes under user actions or user interactions.
16:50
Speaker A
from selenium 4 onwards they have replaced this Json protocol to w3c protocol so this is a kind of a protocol or technology through which the web driver methods will talk to the browser okay then execution will happen so if you look at this web driver it works between two layers one is browser
17:09
Speaker A
So normally, what happens is the presentation layer is responsible for presenting the data to the user. So as a user, I can browse all the pages in the browser. I can see everything from the server, but I have not installed anything on my local system, just browsing the pages.
17:27
Speaker A
after receiving this method after call this method what method is doing it is performing action on the browser that means it is an application programming an interface why it is working as an interface between our client and the backend browser between these two layers the web driver
17:46
Speaker A
But actually, from where those pages are coming from? From the database. Yeah, actual data is stored in the database. So this holds the data.
18:06
Speaker A
not have any database but the layers you have to look at okay Java client is one layer browser is another layer and between these two exactly web driver is working so web driver is nothing but it is receiving the request and sending the same request to the browser and action is performed
18:24
Speaker A
Okay, and between these two, there is another layer called business logic layer, which is also called application layer, or we can say web server. Multiple names are there, and this is a mediator between the presentation layer and the database layer.
18:42
Speaker A
text is displayed on the application the text we want to capture so that also we can do some method from web driver get will also get the some information from the browser and that will provide to the again our client okay so that's how web driver works so that's the it is an application
19:00
Speaker A
So what is the purpose of this layer? And what this layer basically contains is business logic. Actual programming will be there inside this. The programmers or developers, whatever the code they have developed, and the actual functional code, actual software, will be installed in this particular layer.
19:19
Speaker A
browser only three components but why I'm calling web driver an interface API because it is working as an interface between our client program which is Java program and browser so our Java program directly cannot interact with the browser so we need to call some web driver method and web driver
19:41
Speaker A
So what exactly is happening is whenever you're sending some request, because whenever you hit the URL or when you click on the submit button or when you're browsing the data, basically what happens is one request will go to the server.
19:59
Speaker A
be there AP will get the data from the database and then it will provide the presentation layer but here instead of presentation layer we have a Java program instead of web server we have a web web driver instead of DB we have a browser okay actual actions will be happened on the browser
20:20
Speaker A
Okay, one request, user request, will go to the server, and when I hit the server in t...
20:39
Speaker A
action will be performed on the browser here the data will be processed on the database so like that we need to comp okay so the database is uh Java interface is what web driver is what it is an interface and it is also an API it is acting as an API application programming interface the
20:58
Speaker A
web dver method in the sense what it is also programming code right web driver method is what programming code so it is assisting to the Java client which is an application or Java application which contains the programs it is acting as an interface between our Java client and the browser
21:17
Speaker A
that is the reason we can also call Web driver is an API okay so these are the three definitions guys if anybody ask you in the interview you should able to explain this just not by giving a sentence you should more explain about this if it is a Java interface why it is a Java interface
21:36
Speaker A
so earlier I told you initially they wanted to develop a framework a kind of an automation uh tool through which they want to automate the web application that is their in initial requirement but in the market there are n number of browsers are there so initially they have created a web
21:54
Speaker A
driver interface and later on they have created so many number of classes okay so that's how web driver is got started not all methods are abstract some methods are public some methods are static some methods are abstract because interface allows the multiple type of methods different methods are
22:14
Speaker A
there in web driver but especially abstract methods are implemented by using remote web driver and later on extended into multiple classes and web driver contains not only abstract method there are public methods also there there are static methods also there so we we will learn
22:29
Speaker A
all those methods in the coming sessions so web driver in the sense what we are going to learn all the methods from the web driver and we are trying to use those methods to perform the actions on the web applications that is our ultimate goal automating the web application is nothing but
22:44
Speaker A
what what actions we do on the web application for testing same actions we will perform through web driver methods and who will call those web driver methods through Java program we have to call those web driver methods today itself I will show you one example how exactly automation uh script will
23:03
Speaker A
work and how exactly it will perform the actions on the browser okay so all three definitions are clear everyone so please confirm in the chat box web driver is one of the component in selenium web driver is a Java interface web driver is an API these are the three definitions of
23:22
Speaker A
webdrive all right now let us see how we can set up the environment so remember this hierarchy because in the coming sessions also I will give more clarity on this but initially just understand this web driver is an interface which is implemented by remote web driver class
23:43
Speaker A
again this remote web driver class extended into Chrome driver Firefox driver and Edge driver and so on so if you want to run your automation on the Chrome browser then we have to use Chrome driver class okay we have to create an object for Chrome driver class through that object we have to call
24:00
Speaker A
Web driver methods similarly if you are automating the test or if you're executing the test on Firefox browser then we have to create an object for Firefox driver and through the object we have to call Web driver methods similarly whichever browser you want to execute your automation test
24:17
Speaker A
cases for that particular class we have to refer we need to create object for that particular class and through that object we have to call the methods and methods will not be different okay whatever methods are then the Chrome driver class same methods are implemented in Firefox
24:33
Speaker A
driver class same methods are implemented in Edge driver class but methods implementation little bit different because all browsers are not exactly the same browser level the architecture level will be different so whatever method is got implemented for example uh there is a get method
24:50
Speaker A
let us say there is a get method is there in web drive and this method is implemented in Chrome driver class in Firefox driver class CL in driver class but internal implementation will be little bit different from one class to another class but same methods are there so if you remember methods
25:08
Speaker A
from one class you can use those methods for all other classes all other classes also having the same methods right so just remember this now come to the environment setup how to set up the environment environment setup web driver envir environment setup so we can do two different
25:32
Speaker A
ways of setup two different approaches are there and uh first approach is we can directly download web driver component web driver in the sense what which contains a n number of classes and all those classes are they have bundled with the jar files so normally if you want to share multiple files to
25:54
Speaker A
somebody someone else how we will share let's say have thousand files or 100 files are there how we will share those fil to somebody else you don't send the files individually right you will jip the files you will compress them and you will jip it and then you will send one single jip file and
26:10
Speaker A
other guy they will extract the jip file and they will get all the files right similarly selenium guys they have created so many interfaces so many classes and those classes are having n number of methods and they will they are available as a open source okay now we need to get all those
26:29
Speaker A
classes all those methods then we have to attach them in the Java project and then we can use them but how they will provide in which format they will provide all the classes methods in the sense jar file format so normally we we have a doip file right similarly if you want to compress
26:46
Speaker A
all the Java classes methods interfaces into single file that is called as a jar file Do jar is an extension jar is Java archiving file Java archiving file so jar contains a bulk of classes and interfaces and everything okay so instead of providing multiple files they have just created
27:07
Speaker A
multiple jar files and they are available in their official websites inin a website we have to get those jar files we have to download the jar files and uh whatever Java project which we created in the eclipse normal Java project so Java project we'll create in workspace right so in the Java
27:27
Speaker A
project itself we need to attach these jar files all the jar files we need to attach into the Java project I'll show you how we can do this so this is all manual process so we need to download the
27:39
Speaker A
jar files from official website that is manually we have to do and once you download the jar files we need to attach them to the Java project that is also manual process again suppose tomorrow the latest version of [ __ ] comes into market then what you have to do you have to again remove the
27:57
Speaker A
existing J files from your project Again download the latest version of Jar files again we have to attach them to your current project this is all manual process okay this is one approach so downloading jar files okay downloading jar files and attaching them to Java project this is one
28:25
Speaker A
approach downloading jar files and attaching to to the attaching them to the Java project in eclipse or ID whatever this is one approach but this approach is totally manual completely manual we don't need to do any automate here this is completely manual and there is some problem
28:42
Speaker A
with this approach okay so first let me show you this approach but not we are not going to prefer this approach normally the second approach is by creating Maven project we do it by creating instead of creating Java project we will create a maven project project Mayan is also a Java
29:00
Speaker A
project but some additional advantages we will get from the May Mayan is a build tool I'll tell you what are those advantages and how to create a Mayan project okay these are the two approaches are there most of the times we use only Mayan project even in the real time projects also we
29:15
Speaker A
will directly create a May one project we don't do anything manually but for your understanding just I will show you both the setups but normally we follow only the second one okay now we'll see the first approach how we can con figure or how we can set up the environment for selenium web
29:32
Speaker A
driver so first of all I can create one workspace I'm going to C drive uh automation so in the my workspaces I'm going to create a new workspace so my workspace name is selenium web driver okay and just creating a folder so that all the files folders automation skript everything everything I
29:58
Speaker A
will store here and this workspace we need to open in our Eclipse so let me open my Eclipse okay so I can just open my Eclipse so I already have my Eclipse so I'm just opening this just a okay so
30:20
Speaker A
when you're launching the eclipse it is asking for the workspace so this is my Eclipse I'm opening so it is asking for the workspace first time right when it is asking or else once you open Eclipse also you can switch to the workspace no matter So currently it is point to the different workspace
30:37
Speaker A
now I'm going to browse and whatever folder I created go to the C drive wherever you created so in automation my workspaces and selenium web driver I'm selecting this folder so from now onwards this is using the workspace and I'm using this workspace by default so I'm just checking the
30:55
Speaker A
box and say launch okay suppose if you already open in your Eclipse okay once you open your Eclipse also you can switch to the workspace if you want so once it is done it opens the eclipse like this and you can close this welcome window now this is a new workspace so I haven't
31:13
Speaker A
see anything here okay suppose you already there uh in your Java programming workspace so earlier you already created Java programming right the workspace if you still want to use workspace you can use it no problem in the same workspace you can create a new project okay so you can continue
31:32
Speaker A
with the existing workspace whatever you created earlier whatever Java programs you have done earlier same Pro same workspace you can continue or else you can if you want you can create a new workspace okay so here I have created my new workspace so in this we have to normally create
31:46
Speaker A
a Java project so let me create a new Java project so here I'm giving a name as web driver project this is my new Java project actually so by default web driver is also Java only so Java project and
32:02
Speaker A
here we don't select any module so unselect this module and every concept this module concept is there in advanced Java like more than Java 15 Java 2021 developers need this concept but we don't need so remove this module kind of thing and then click on finish so this will create
32:18
Speaker A
a normal Java project right it's a normal Java project so you can just create normal packages Java programming everything you can practice it but in addition we have to attach web driver okay we need to download the web driver jar files and we have to attach them to the existing Java
32:36
Speaker A
project that's how we need to do configuration manually so once you created your Java project this is your workspace okay now how to download selenium jar FES now we need to go to selenium official web page just select for selenium search for selenium and selenium dodev this is official
32:55
Speaker A
web page just click on it and once you click on it here you can see three components web driver ID selum grid now we need to go to the download section here and you can see there are multiple
33:09
Speaker A
languages currently supported so now we are going to use Java so the latest version is what 4.8.1 so this is the latest version as of now we are using it so I'm also mentioning the version number this is the current version so I'm going to click on this and it will automatically
33:30
Speaker A
download all the jar files yeah so now I click on it now you can see it is downloading a gy file now once it is downloaded just go to this particular folder and wherever it is downloaded you can see here and once you downloaded you have to extract this Gip file so okay can say extract
33:50
Speaker A
all so once you extracted uh you will see a new folder here which contains all the jar file okay so once you have seen it will show you where exactly you want to extract so click on extract so once it is done all the files jip files uh
34:14
Speaker A
J file is extracted into multiple files so it will take few seconds of time so once it is done we can attach those jar files to your Java project in eclipse so let it download so what we have done in the first step downloading J fil
34:46
Speaker A
attaching them into Java project so in this approach first we created new Java project or else you can use existing Java project okay earlier you already created Java project right in your Eclipse you have created all the Java programs so on the same project you can still continue okay you can just
35:07
Speaker A
additionally add new jar files you can so created new Java project then what you have done downloaded selenium or we can say web driver jar files jars in the form of zip file and extracted okay so now once we extracted this file we need to attach them
35:31
Speaker A
into the Java project that's it so it is think still it is extracting so let it complete the process and once it is completed the process we need to add all the jar files to your current project which you have created in your Eclipse so that is a process so let me maximize this for
36:11
Speaker A
and this is just for your information I'm just showing you this approach but normally we don't follow this we always follow the Mayan Mayan concept for browser specific drivers are not no need to download because from selum 4 onwards even
37:07
Speaker A
browser specific drivers also bundled with this jar files but earlier in the older versions of selenium each browser there specific drivers are there okay so we have to download them but now we don't need to download any specific drivers for the browser so selenium guys are
37:25
Speaker A
already embedded those drivers into selenium job FES and from selum 4 onwards okay but if you are using previous versions older versions then uh you have to download browser specific drivers separately but now no now nowadays you don't need that one in the latest versions of
37:43
Speaker A
s it is taking some time let me wait for a few seconds and once you downloaded the jar files next we need to attach jars to Java project so these are the three steps in the first approach everything is manually we have to do so the problem with this approach is suppose uh tomorrow
38:18
Speaker A
if the new version comes now I want to incorporate that version so what you have to do is whatever jars you already attached to your current project you have to delete all of them manually again you have to download the latest jar files again you have to do add you need to add them to the project
38:35
Speaker A
so this is a TDS process everything we have to do manually even downloading is also we are doing manually right so as of now I am downloading them so this process is also have done manually so this is a problem so instead of doing it we will do May one project normal so if you want to know
38:55
Speaker A
which browser it is supporting you can just go to selenium official website so here they have provided Which languages are currently supporting and if you scroll down to this page here you will see what are the different browsers it will support you can just click on here so these
39:12
Speaker A
are the current browsers s is supporting it is not id id is a totally different tool should not compare okay Mayan is Mayan is not an ID Mayan is a build tool okay we'll see that in the coming
39:28
Speaker A
sessions but today I will give you some basic introduction about Mayan but you will see the M exact usage of May in the CSD Concepts but today I will just give you some basic introduction what what is the additional benefit you will get when you create a mavan project okay so these are the
39:45
Speaker A
browsers [ __ ] supported so all the information is available in their official website you don't need to worry Firefox Internet Explorer is supported till 10 because this is already deicated by Microsoft so currently there are no one is using Internet Explorer so we can simply
40:01
Speaker A
ignore this instead they have introduced the some other browser called Edge so Microsoft this is also from Microsoft so instead of using Internet Explorer we can prefer to use always edge browser so Firefox Safari Opera Chrome and Edge so these are the browsers currently celum is supported
40:22
Speaker A
and operating systems also currently these are the three operating system Windows Mac Linux supported and programming languages again here mentioned here these are the five programming languages are supported Shar Ruby python JavaScript and Java okay all the information is available in
40:40
Speaker A
website itself and if people are using selenium with python and then they have to download this one Python and if you're using selenium with shot they will download this one so we are currently using S with Java so we are going to download this one okay this is the difference right so let it
41:01
Speaker A
complete it is taking more time so meanwhile if you want you guys can try but I don't prefer this approach otherwise if you are having confusion just let it be leave it no problem I'm just for your understanding standing I'm showing you this
41:58
Speaker A
approach yeah so now it is extracted so downloaded and also extracted so downloading is not taking much time but extraction is taking some time so once extracted you will see a new folder called 4181 you can see this is the actual celum JV files okay so now what we have to do is we have to keep
42:29
Speaker A
the folder here or else you can keep it somewhere else so what I can do is I can just copy this from here and uh I will put somewhere in the C drive in automation somewhere so here I will keep it so you
42:44
Speaker A
can keep anywhere okay so I'm just keeping it here C drive in automation I have this [ __ ] Java so now this is a step one so we have created a new Java project we have downloaded web driver jars
42:55
Speaker A
in the form of Gip and then we have extracted so once extracted we need to attach those extracted files to your current Java project whichever you created in your Eclipse now go to eclipse and this is the project which is got created so how we can attach those jar file you can simply do like
43:13
Speaker A
this you can say right click on the project go to properties and in the properties we have something called Java build path go to Java build path in the Java build path you can see multiple sections need to go to library section becauseum jar files are libraries so go to library section in this by
43:37
Speaker A
default you can see some JRE is already configured under module path we need to go to class path okay we need to go to the class path in the class path you need to click on ADD external jars there are
43:53
Speaker A
two options are there add jars add external jars so selin web drivers are basically external jars which you have downloaded so we need to click on this add external jars and now wherever you have these jar files wherever you kept those jar files you need to go to that location so
44:10
Speaker A
this is a folder which contains the jar files so you need to select all the jar file you can just press shift and down arrow key it will select all the jar files and then open okay now you can see
44:25
Speaker A
all the jar fils are attached under Class B and one more time select the class path and click on ADD external jars and we have left this lip folder earlier so we need to go to inside the lib also
44:37
Speaker A
and select all the jars from the lib folder then open it okay so we have to attach each and every jar file from the folder which we have extracted we should not miss even a single jar file so once
44:52
Speaker A
it is attached then apply and close that's it so once you have done it you can see referenced libraries you can see one more section under the reference libraries you can see all the jar files which are attached to your project so from now onwards this project becomes a web driver so
45:12
Speaker A
not only Java programs we can additionally create automation scripts in this particular project okay so this is a manual configuration as a beginner you can try this but actually we don't follow this the problem with this approach is suppose you already configured this project with this
45:30
Speaker A
particular version like 4.8.1 so suppose tomorrow let's say 4.8.2 comes in the market or 5.0 come to the market you want to upgrade with the latest version then what you have to do now you have to again go to this reference libraries go to properties libraries Java build path libraries
45:50
Speaker A
you need to select all of them like this whatever jars earlier you have added you need to select all of them and then you have to remove them first and once it is removed then you can Again download the
46:02
Speaker A
latest jar files you have to extract them and then again you need to attach to your current project so this is a again manual process which you have to do this is the problem with this approach okay that's the reason we don't follow this approach okay now we'll go to the second approach and if
46:21
Speaker A
you want to try you can try just one try otherwise you can leave it ignore it no problem okay I'm just for your understanding I've shown you this approach but this is not recommended this is not recommended okay now let us see how we can do the second approach and how we can overcome the manual
46:46
Speaker A
stuff everything we can do automatically so may one project itself it automatically download all the Jarone from the website it will automatically attach to the project even tomorrow there any new version CES that will also automatically do through MAV project everything is automated
47:02
Speaker A
now we'll see how we can do through MAV project so Mayan is basically a build tool normally devop steam will use about may1 in CIAA configuration C continuous integration configurations but mavan is also having more number of advantages as an automation tester we can also use MAV to
47:21
Speaker A
get those advantages or to get those benefits so how we can create a Mayan project so Mayan is a small tool a build tool or we can say an extension or a plug-in and whenever you install Eclipse by
47:34
Speaker A
default you will get a May one so you no need to install may1 separately by default Eclipse will come with the May one even if you're using inell also by default you will get a Mayan in that particular IDs so and again Mayan is also related to Java only on top of java may1 components are
47:53
Speaker A
added so may1 also inter internally it is a Java only but additional benefits you will get from the may now let's see how to create a Mayan project so I have created web driver project right so I'm just doing deleting this project as for now delete this I don't need this and
48:10
Speaker A
when you're deleting it you have to select this option if you're not selecting this option this project will be deleted only from Eclipse but still there in the workspace so if you want to delete this from workspace also then you have to select this option delete project contents on disk
48:25
Speaker A
cannot be undergone so just delete everything so everything is got deleted okay now as of now I'm there in the same workspace now I want to create a Mayan project the second approach so creating a Mayan project how to create a May one project very simple instead of creating a Java project there is
48:45
Speaker A
an option called create a May one project you can see the second link is there you can also create from the file menu go to the file new instead of java project you have to take a mavan project so
48:57
Speaker A
take this Mayan project and uh here it will show you multiple options so create a simple project so select the first checkbox otherwise it will give you some default templates of the project we don't need any default templates we have to create our own template so create a simple project skip
49:17
Speaker A
architect types architect archetype is nothing but a templat so we are going to skip that section we don't need so select the first checkbox second Che checkbox let it be there so may project will be created in our current workspace simply click on the next button and here we have to provide
49:35
Speaker A
few informations so group ID we have to provide so basically group ID is related to project name so here I'm creating a project name I say selenium web driver and same group ID you have to give uh in the artifact ID so group ID artifact ID same thing whatever you have given here same thing you
49:58
Speaker A
put in the artifact ID and rest of the things are optional you can just leave for now just provide only group ID artifact ID so that with these names the new May project will be created so once you
50:10
Speaker A
provided just click on the finish right so once you click on the finish it is got created a new project which is actually may project May in the sense again it is underlaying we it is having Java only okay so even in the mavan project also we can create a Java programs we can execute everything
50:31
Speaker A
we can do whatever we have done earlier so this is how we can create a mavan project okay so once you created your Mayan project you will by default you will get some packages along with some pal red XML so we need to understand few of them here so once you created your M project by default Java
50:50
Speaker A
is associated with this see here Java is already associated with this project along with this Java it is also given some default packages SRC main Java SRC main resources SRC test Java SRC tester resources so these are the four default packages which is provided so normally SRC main Java SRC
51:12
Speaker A
main resources used by developers SSC test Java s test resources are used by the testers or used for testing purpose and first two packages used for development purpose all the development code will be part of SRC main Java and when I do some development if we need any third party files or
51:32
Speaker A
resources we will keep inside SRC main resources similarly whenever you want to create automation test cases that will be part of ss test Java and when you're creating automation test cases if you need any third party files like Excel sheets or notepad files or any property files we will
51:49
Speaker A
keep them inside the SRC test resources so for automation purpose we need these two packages and first two packages we don't need so we can simply select them and then delete them so right click and then delete even if you keep them no problem but anyway we are not going to use them
52:08
Speaker A
okay these are the only two packages which we are going to use again resources folder I will later use it but for now let us focus on SRC test Java this is the main root package for Maya and inside this only we will create another sub packages and we will create all the test script
52:25
Speaker A
and everything now these are all default files and p. XML this is the main file for one project so as I said everything will do automatically right so that thing will happen through p. XML so Mayan project is always have p. XML file by default only through pom.xml we can achieve everything
52:47
Speaker A
in May one so downloading the jar files attaching them to your current project and tomor if you want to remove the existing jar file we can remove them all these things are happen through form. XML file okay so now we'll see this is just created your only May project still we have not configured
53:04
Speaker A
with web driver it is just a Mayan project so now we need to configure web driver so to configure web driver what we can do is earlier we have downloaded all the jar files manually right so now we don't need to download anything manually so what we can do is in p. XML if I open the p. X
53:27
Speaker A
ml in the pal. XML if you look at this a small piece of XML code you can see so this is a basic default code which you can see here this is formed XML XML code and there are
53:45
Speaker A
some tags are there you can see project and closing tag model version group ID artifact ID version there's some default information is there let it be there so now we need to add here something what we need to add in the p. XML we have something called
54:04
Speaker A
dependencies dependencies remember this terminology in the p. XML we have something called dependencies okay what is dependency means so as of now in this mavan project what extra we need is CIA web driver job first so that is a dependency suppose tomorrow if
54:32
Speaker A
you want to work with Excel sheets I need to download third party dependency Apache POI suppose tomorrow if you want to use with test NG then you have to get test dependency so dependency means something which we need in our existing project that's called dependency so
54:52
Speaker A
as of now we need web driver jar files s web driver we need for this project so that is a dependency so that dependency we need to add in form. Excel so how we can get the dependency so
55:06
Speaker A
all the dependencies are available in mvn repository website you need to go to m mvn repository search for this one mvn repository and you will go to this particular website this is the official website from this we will get all the dependencies required for form. XML
55:29
Speaker A
okay this is called Mayan Global repository okay in the coming sessions I will elaborate this but as of now just remember few things so whatever dependencies we required for our projects all the dependencies are available in mvn repository. comom this is official website of Mayan and
55:52
Speaker A
they will maintain all the dependencies in their repositories in the remote depositories so in this we can search for our dependency which dependency we need selenium Java dependency just search for selenium and Java and click on the search button now we can see you can see different dependencies
56:15
Speaker A
are disted out here so this is a dependency which we need selenium Java just click on it now we can see all the versions are available so as of now what is the latest version of ium this is the one February 20th it is got released 4.8.1 so whichever version of dependency we
56:34
Speaker A
required we need to get it so click on this latest version now you can see this is small piece of XML this is called as a dependency this small piece of code is called as a dependency now copy this dependency and paste that inside the p.x that's it very simple just get the dependency from
56:59
Speaker A
there and add the dependency in the PEX but before specifying this you need to add one additional tag called dependencies opening tag and closing tag and inside this opening and closing tag you need to keep all the dependencies like this in future we will download so many dependencies we will add
57:21
Speaker A
so many dependencies but as of now we require only one dependency that is selenium Java depend depy that we have added here okay now you see the magic here as soon as you added this dependency once you save your pom.xml what will happen is this pom.xml dependency will download all the jar files and
57:45
Speaker A
attach them to your current project automatically happen that's a magic we don't need to do anything just we have added one dependency and whichever version We specified here corresponding version J files will be downloaded and attached them to your current project just observe I'm saving this
58:05
Speaker A
ped XML or update it once okay can simply right click go to may just update project whenever you do some change in the pom.xml try to update your project how to update right click on the project go to May one and then update project so once it is done and also at the time of updating select
58:25
Speaker A
this option for update of snapshot or releases sometimes it will not properly download okay in that case you will face an problem then you select this option force update then click on okay so when you do this what will happen is it will start downloading all the jar files selenium
58:46
Speaker A
web driver jar files and also attach them to your project now just observe you can see there is a new thing something is ADD Mayan dependencies if you expand this see these are all selenium jar files can see selenium dev2 Firefox htpi Json you can see these are all selenium jar files okay
59:11
Speaker A
so this is a how we can automatically create M project and automatically download all the J so this dependency will take care of everything so once it is done we are ready to go so this is our project so may project configured with a selenium web driver so through pomed XML we can
59:31
Speaker A
control everything from the project and if you remove this pomed XML the Mayan project will not work so the entire Mayan project will work based on the pomed XML so what we have done is we have just created a new mavan project so what are the steps created new mavon project in eclipse
59:57
Speaker A
sorry created a new A1 project in eclipse and then what we have done we have added web driver dependency in pom.xml and then updated that's it so now all the jar files are automatically downloaded and our project is good to go okay yes in the dependencies everything
60:34
Speaker A
whatever we required for the mavan dependency everything is got added everything is part of the jar files okay so now we are ready to go so this is the project which we are going to use for our automation okay you also everyone should also follow MAV project second approach don't go
60:54
Speaker A
with the first approach okay and suppose tomorrow some new version came into market then how we can do it how we can up upgrade your project very easy just go to pom.xml and change the version that's it so tomorrow let's say 4.9 came at 4.20 came so just change the version number then again
61:15
Speaker A
one more time update the project go to May one and just update the project so then what will happen the old jars will automatically removed by m whatever the dependencies we already added it will automatically removed by Mayan and whichever the newer version We specify here it will get download
61:33
Speaker A
all the latest jar files and automatically attach it with the project so this is how we can use mavan project okay so you can you can see MAV project option you can see if you going to file go
61:48
Speaker A
to the new here you can see MAV project if you're not visible here you can go to other sometimes it is not visible here so then what you can do is go to other click on other and here in this list you
62:00
Speaker A
can see May one project you can see May one option here and expand this may one option select the May one project and then click on the next and proceed for that okay sometimes if you're not able to see
62:11
Speaker A
the beginning you can do like this you can go to others and then you can find the Mayan I'm going to show you multiple times go to Mayan and then go to other and uh go to mavan and then select mavan
62:29
Speaker A
project and next to proceed further and if you face any issues I will check later but this is the process of creating a Mayan project update b. XML and get all the jar FS so everybody is clear so far these are the two approaches which you have and the second approach is always recommended
62:53
Speaker A
second approach is always recom can can everybody can do it yourself just creating a MAV project update p. XML with the dependency that's it nothing else okay so anyway I will share this p.
63:10
Speaker A
XML you guys just copy the dependency or else you can go to this link from this link you can get the dependency okay web driver so web driver dependency link so you can open this link and copy the dependency and attach them into the bombex
63:39
Speaker A
okay so everybody is clear please confirm in the chat box everyone the process you know right you can just try later the process how to create a May one project how to update pom.xml forget about the first one the first one everything we have to do manually again that is a TD process
63:57
Speaker A
so if you just create a m project just add one dependency in pet XML that's it it is ready to go okay now so we are created MAV project so now we'll see how we can create a simple automation
64:13
Speaker A
scripts very basic automation script I will show you how to create and how to execute how exactly we can ACH automation through web driver so today is day 21 I guess so what what I can do is I will create a new package for today SS test Java inside this I'm going to create a new
64:32
Speaker A
package just like every day we are creating new project and we are doing multiple program same way create a new package so inside this I'm going to create my new package called day 21 click on finish so now I created a new package under SRC test Java inside this I'm going to create a new
64:55
Speaker A
class just like a normal Java program create a new class and I'll name it as it's my first uh test or first test case and I'm taking main method also just like a normal Java program click on the finish right so this is normal Java program which have created all right so you can
65:19
Speaker A
also write normal Java programs no problem because basically it is Java only right so underlaying underlayer is Java only Mayan Java web everything is in Java only so we can still normally create a normal Java program we can execute see I'm just creating a simple program
65:34
Speaker A
here system pint just testing so normal Java program can just run as Java application it will execute okay simply Java is executed so you can simply write a Java program like this you can also create Java progress no problem yeah now we are going to write an automation script in
66:00
Speaker A
this so before writing any automation script we have to know the test case so what are the steps we have to automate manual steps so if you know the manual step exactly we can convert into automation format okay so here I'm taking one test case so let me take one test case here so this is
66:22
Speaker A
my test case the first step I want to launch my Chrome browser then I want to open this URL this is the application URL I want to open on the Chrome browser okay now I want to check I want to
66:36
Speaker A
check the title of the page is this one or not title of the page and after verifying the title I will close my browser these are the four steps just four steps I'll open the Chrome browser and open this URL then check the title of the pages your store or not and then close the browser so
66:56
Speaker A
every test case should have some validation point so what is a validation point in this test case third step third step is a validation Point okay now let us see how we can automate this test case very basic very simple test case and we will see how we can use web driver methods what are the
67:14
Speaker A
methods are there how can we access okay we'll see automation now step number one is what launching the browser step number one launching the browser so how to launch the browser so whatever step you want to automate everything we have to use web driver methods in the beginning I told you right
67:36
Speaker A
web driver is an interface which is implemented by many classes so if you want to access those methods what we have to do now first we have to create an object for the particular class and which browser we are going to use it here is Chrome browser so we have to first create a chrome
67:52
Speaker A
driver class object that's a step number one oh only through that object we can access required methods so which class we have to use Chrome driver class Chrome driver and Driver equal to new Chrome driver this is the first step okay so we need to import because these are all external
68:16
Speaker A
classes we have to import required packages so place the cursor it will show you import package and if you're not getting these import packages properly what are that mean you have not added the dependency properly and if you're not having jar files then you will not see these suggested
68:34
Speaker A
options so I'm importing Chrome driver class from this particular package org. open. selenium do chrome. Chrome driver okay now this is how we need to First create an object why we created an object for Chrome driver class because we want to launch the browser which is Chrome browser okay so as
68:58
Speaker A
soon as you created an object what will happen is this chrome driver class is having one Constructor default Constructor and that Constructor will automatically launch your Chrome so how they have implemented the back end stuff we don't need okay we don't need to know how exactly
69:18
Speaker A
they have implemented the backand side we need to know how to use those methods for our automation purpose okay okay so whenever you create a chrome driver class object internally the Chrome driver Constructor will automatically invoke and that Constructor will launch Chrome browser remember
69:40
Speaker A
this okay let me run this code just one single step I created execute and see what will happen run as Java application just like a normal Java program just observe here as soon as I executed now you can see it is launched my Chrome browser it is automatically launched my Chrome browser
69:58
Speaker A
and it is also saying Chrome is being controlled by automated test software through automation we have launched this particular browser with single step just by creating Chrome driver class object it is launched by Chrome driver Chrome browser and who is done this this is done by Constructor which
70:19
Speaker A
is there in the Chrome driver class and still we have not open any URL here just we launched only browser okay close this for now so step number one launch browser it is done just by creating an object of CHR driver this is done now same step can we write like this I can say
70:42
Speaker A
web driver driver equal to new Chrome driver can we write like this yes why because web driver is what parent only right CHR driver is D from remote web driver class that is also derived from web driver so obviously it is a parent so this web driver driver equal to new Chrome
71:02
Speaker A
driver also we can specify but this web driver we have to import okay this web driver we have to import so it is not showing package properly so we can just import you need to write manually import dot web driver so do we need to do tab casting here is it really required so this is
71:34
Speaker A
upcasting yes you are right so this is the child we are we are trying to store in the parent class variable right so here this is upcasting so we don't need to specify anything here so it can go
71:48
Speaker A
with this approach or you can go with the this sub both are correct all right so now step one step number one is done so so this step is also correct let's try to execute one more time run
71:59
Speaker A
as Java application so this will automatically launch our Chrome browser now you can see the browser is successfully launched so either you can go with this one or you can go with this approach but this is a second approach most of the times we prefer okay why because tomorrow if I create
72:19
Speaker A
another browser object I still that I can store in the driver right if you create a web driver driver variable I can store Chrome driver object I can store Edge driver object I can Store Firefox driver object any type of object I can store in this right but if you create this approach I can
72:37
Speaker A
store only Chrome driver object in this variable I cannot store anything else right so that's the reason most of the times we prefer this particular approach web driver driver equal to new chrone dri this driver is a just a reference variable you can put any name anything is all right step
72:53
Speaker A
number one is done now come to the second step number two open URL as soon as the step is open the browser we have to open this URL on that particular browser how to open this so Second Step very important listen this care very easy if you know Java automation is very very easy
73:16
Speaker A
just only thing is you need to know some methods yeah so how to open the URL on the browser very simple we already created driver right so so just using the object we have to call one method called
73:29
Speaker A
these are all web driver methods you can see what are all methods are available here these are all web driver related methods so by using these methods we can perform various types of operations or actions on the web page now here we have a method called get get is a method so
73:46
Speaker A
this get method will take a parameter string type of parameter which is basically called URL of the application that you have to pass so this is the URL I'm passing as a parameter in the form of string okay so from the driver object I'm calling get method what this get method will
74:05
Speaker A
these are all predefined methods and predefined classes so we don't need to know what exactly they have written because they have already done and provide us so we need to know how to use it in our automation so what is this get method will do is the get method will take URL as a parameter
74:23
Speaker A
and open this URL on the browser which is is already launched by this first statement okay in the first step we already launched our browser in the same browser the get method will open this URL very simple let me execute and show it just run as Java application okay now it is launched
74:45
Speaker A
my browser see it is launched my browser and also open this URL so now we got an application okay now step two is also also done now step three is what we need to validate the title should be your
75:01
Speaker A
store how we can validate the title just observe where we can find the title on the application for example let's take this application and this is the application right in this if you see uh view pay Source right click on view pay Source at the beginning you can see the title so you can
75:22
Speaker A
see here the title this is called title here it will show you okay or you can just inspect this and you can just go to the header part in the title you can see your store this is a title
75:36
Speaker A
actually in the view pay source is somehow it is not displaying but here it is displaying your store is actual title so we need to validate the title of this page we have to every page is having a unique title if the pages got changed for example I'm clicking on MacBook now I go to
75:52
Speaker A
MacBook page so now the title of this page will be different and once you go to ad cart and AD cart page is different okay and the title of the ad cart page is different so each and every page
76:04
Speaker A
is having different titles now as per my test case I want to validate that homepage title is what my store so how to validate so that's the third step third step is what validation Point third step so before valid Ting the title is your store or not we need to capture the title from the application
76:31
Speaker A
actual title is what and the application actual title is what that we need to capture compare with expected title this is our expected title what we are expecting but actual title sometimes will be different if you find any mismatch between actual title and expected title then your test is failed
76:49
Speaker A
so how to capture the title of the web page so to capture the actual title of the web page again we have one more method called driver. get title this is the method so we don't need to pass
77:03
Speaker A
any parameter so this method will automatically capture the title of the web page that I'm going to store in a string variable this is our actual title from the web page actual title from the web page so get title is a method which we can access through driver instance so this method will return
77:24
Speaker A
the title of the actual web page and we already have our own title right expected title is what your store that we need to compare by using IF condition if yeah now tell me how to compare the strings how to compare the strings so this is the actual title this is your expected title
77:45
Speaker A
now both we need to compare so actual title dot equals actual title is a string right equals what is our expected title this is our expected title that you can specify in the double quotes specify this in the double quotes we have to specify this okay and actual title dot equals this
78:12
Speaker A
one and what this will return if both are equal both are equal returns true if both are not equal returns false if both are equals returns true then condition become false condition becomes true if both are not equal the condition become false so assume if both are equal true then what
78:33
Speaker A
we should say test case passed or test passed if both are not equal then what we should say test failed system do p tell simply say yes failed that's it so third step is also done so what we have done we captured the title of the page and stored in a variable and then we
79:00
Speaker A
compare with our expected value and both are same actual and expected are same test pass if actual and expected is not same then test will fail so third step is also done now what is the last step closing the browser so as soon as our test case is got executed we can
79:20
Speaker A
close the browser right no need of browser so how to close it we have two approaches everything step by step so what you can do is um as soon as okay so here before closing I will or else I can just comment the statement so that you can see
80:37
Speaker A
this so I'm not closing the browser so it is launching my browser now open the URL and validate the title also you can see test passed test pass and you can close this manually now instead of closing manually I'm using this option driver. close so when you execute this it will
81:00
Speaker A
automatically launch everything and execution will happen and test is passed very it will go very very faster because it's small test case right but if you have any number of steps you need to navigate between multiple Pages then it will take time so that we can see each and
81:16
Speaker A
every action on the browser but it's very fast so this is how we can simply automate the test case very very simp simple only thing is you have to know what are all methods we have to use in which place we have to use if you know this you can easily write automation test cases it's
81:36
Speaker A
very very basic and very simple test case okay so we launch the browser by creating an object and open the URL by using get method and capture the title of the Page by using get title method and then compare with the actual title both are equal test part both are not equal test that's
81:57
Speaker A
okay and finally we are closing the browser so this is how we can simply automate the test case and most important thing is how to interact with the different type of elements so in the web page not only title right there are n number of things we need to verify suppose if you take
82:18
Speaker A
any page like this there are n number of things are there in the web page we have input boxes okay and we have links we have images we have checkboxes many things are there so how we can automate all those elements how we can interact with those elements for every type of element
82:37
Speaker A
every type of action there are different type of methods are available you want to click on a button there is a method available if you want to provide the text in the input box suppose here the search box is there I want to enter something like this so there is a method called send Keys is
82:53
Speaker A
available and if you want to click on the search button The Click method is available okay so for every type of element so whatever you can see on the web page we call it as a element web element
83:05
Speaker A
so image is a web one web element okay and links are web elements buttons are web elements input input boxes are web elements and sometimes you can see drop down boxes they are web elements radio buttons are web elements so these are all different type of web elements so how to interact
83:22
Speaker A
with those web elements so there are different methods are there in selenium web driver by using those methods we can interact with them we can perform actions on the web elements but before that we have to identify those elements how our Java code how our Java program will exactly
83:40
Speaker A
identify the element because there are n number of elements are there I want to exactly provide the text in the input box and how our automation code or automation script will identify these element because there are n number of elements out there okay for example let's say there are same kind of
83:59
Speaker A
elements we can see sometimes we can see same kind of elements on the web page look at this web page here you can see two input boxes now I want to pass input uh text only in the username
84:11
Speaker A
input box how exactly our automation will identify and we need to exactly pass password value so if you have multiple input boxes how we can exactly locate that element so these are all possible by using locators concept so how many ways we can locate the element how many ways we can identify
84:31
Speaker A
the element that is all one part and once you identify the element then what kind of action we have to perform on it that is another part so entire automation you are going to focus only on two things one is identifying the element or locating the element once you locate element
84:51
Speaker A
what kind of action to be performed if it is a button we have to per from click action if it is input box we have to pass a text that is a one type of option if it is a link we have to
85:01
Speaker A
click on if it is a drop down we have to select one option from the drop like that every element every web element is having different type of actions to be performed for them we have action methods are available similarly every element we can locate different type of elements different
85:18
Speaker A
type of locators also there like by using ID we can locate by using name we can for every web element having number of attributes basically we can call attribute like every person having different type of attribute like name height color and everything right similarly every web
85:34
Speaker A
element in the web page is having certain number of attributes and those attributes we can use to locate the elements okay this is all part of automation so from the next class we will continue so first thing we will see how we can locate the elements that's the first part once you're able to
85:52
Speaker A
locate the element then what kind of actions we can perform for that's the second part so these two parts we will learn in the next sessions it is very huge concept takes around 10 to 15 sessions because we are going to deal with a different type of element different type of actions we will
86:08
Speaker A
perform and different type of death cases we are going to automate so slowly you will learn step by step step by step and uh then slowly after few days after five after 10 sessions or 15 sessions I will try to incorporate testng features also so that we can generate the reports we can do
86:25
Speaker A
parallel testing parameterization there n number of topics are there so we'll discuss all of them in the coming sessions but today what you have to do is try to set up the environment create a new project Mayan project and whatever Eclipse you're using currently just uh follow with that
86:42
Speaker A
and whatever Java project you already created so far right if you want you can make the same project project or else try to create a maven project new project on the same workspace you can create a new Maven project update p. XML and try to create a small test case like this okay
87:00
Speaker A
also I will give you one more test case for assignment you guys can try this and this is for assignment same steps but just application is got changed open the browser Chrome browser and open the URL and verify the title should be this or not okay for example let's say same test
87:21
Speaker A
case I want to run my edge browser then how we can do it edge browser so this particular statement will launch Chrome browser right this is for Chrome browser suppose same test case I want to run my edge browser so simply what you can do is you have to create object
87:40
Speaker A
for edge browser that's it web driver driver equal to new edge browser that's it so Edge driver right so now we need to import this Edge driver class that's it there's only one statement you have to change and rest of them again same because all methods are same browser to browser
88:04
Speaker A
there is no much change okay all methods are same only the object will change so if I execute now this will execute on edge browser can just let me show you run as Java application so this time it will execute on edge browser now we can see it is already launched okay let me launch
88:24
Speaker A
one more time okay I'll comment this statement for now so that you can see the edge browser is launching you can see this is my edge browser see Microsoft Edge is being controlled by automated test software so this is edge browser and my test is got executed so here you can see test
88:47
Speaker A
is got passed so after execution if you want to close it you can use close or quit anything is fine and sometimes it will throw some socket exception you can just ignore that exception for now I'm just driver. close I have executed see my test got executed and also passed but
89:05
Speaker A
after that when I closing the browser I'm getting some exception warning it is not an error okay it is just a warning thrown by web driver so we can just ignore this for now and also we can use pit command in of driver. Cl we can also use Twitter I can say run as Java
89:25
Speaker A
application so this will also do the same thing so edge browser opened executed launch everything is done browser is also got closed right so this is how we can execute on the edge browser so but before the prerequisite is what you need to have these browsers on your system you need
89:46
Speaker A
to install them I think or is having Windows they have the edge browser Chrome browser also should be installed manually okay then only these things will work and if you're not having Chrome browser and edge browser and if you're trying to launch them through automation it won't work okay
90:04
Speaker A
and that is one thing you need to check second thing if you already have a browser try to have a latest version okay so how we can update your browser suppose if you open my Chrome browser go here there is settings options there or can just go to help go to about Google Chrome okay
90:24
Speaker A
go to this option and here it will show you Chrome is updated or not okay try to upgrade with the latest version so Chrome is up to date so this message should display and these are the prerequisite if you have a Firefox it is also safe because I'm not using Firefox but that's
90:43
Speaker A
not recommended because it's very very slow Firefox execution is always very slow so most of our automation sessions I will try to use edge browser and Chrome browser if you want to use Firefox you have to install Firefox browser then you can create like this here you can change
90:59
Speaker A
like this web driver driver equal to new Firefox driver new Firefox driver so this is the class which is implemented Firefox so that also you need to import so now when I execute this test case it will execute on the Firefox browser but currently I don't have a Firefox browser
91:23
Speaker A
so this will an error and executing this Java run application see I don't have installation of Firefox on my system so it cannot execute first of all it will try to launch but it could not find anywhere in the Firefox so definitely it will give you some error so that is a prerequisite
91:47
Speaker A
whichever browser you want to launch oh I have I think I already have Firefox just a moment okay okay so I already have Firefox let me run it run as Java but it is very very slow guys I
92:09
Speaker A
don't recommend the Firefox browser see here this is my Firefox browser so launching my application everything is done on my Firefox so my test is also got passed okay so whichever browser you want to execute you can just configure that browser
92:29
Speaker A
just change this object that's it so if you if you want executing Chrome browser use Chrome driver class object if you want to run an edge browser then you use Edge driver and if you want to run on Firefox use Firefox driver object okay so use only one of them at a time you cannot use all of
92:48
Speaker A
them one time only one driver object will focus only one browser at a time so use this option okay no no no if your browser is not installed on your system this won't work okay that is a prerequisite I'm saying if you want to work with the Chrome browser in automation you
93:12
Speaker A
should install Chrome browser on your system Chrome browser should be there similarly Edge driver should edge browser should be there and Firefox browser should be there if you have these browsers installed on your system then only your automation will run otherwise it will not page
93:30
Speaker A
inspection locating the elements everything I will discuss in the next class okay that's the reason I'm stopping here for today I'm not going into the next stuff so tomorrow session I will discuss about the how many ways we can locate the element how to interact with the elements before
93:47
Speaker A
clicking on okay button first we need to locate that element we need to identify this okay before passing the text in input box we have to identify the input box so before performing any action on the element identification is most important so that part we will discuss in the next two three
94:04
Speaker A
sessions it will take approximately two to three sessions it will take for locating elements so once you know how to locate the elements then easily we can perform the actions but locating the web elements is a very big challenge in automation because there are n number of ways
94:20
Speaker A
out there so yes Chrome ium driver is newly new class which is introduced in selenium 3.x so in the previously I told you one hierarchy right so the web driver interface is imple implemented by remote web driver class this web driver remote class is again extended into multiple classes
94:41
Speaker A
right this is actually selum 3 this is how but in selenium 4 they have introduced one more new class between remote web driver and chrome driver that is called chromium driver so let me show you how exactly this is the structure initially web driver is a an interface and this is implemented
95:08
Speaker A
by remote web driver class and this is again implemented by mult extend from multiple classes one class is called chromium driver another one is what Firefox Opera and so on and this again chromium driver is having two sub classes one is Chrome driver class Edge driver class okay
95:43
Speaker A
Edge driver Chrome driver are using same kind of a driver that's the reason they put these two under chromium driver actually I have not discussed this but actually remote driver is again extended into chromium driver class Firefox driver class Opera class and many more classes are there and
96:00
Speaker A
this chromium driver class again extended into Chrome driver and Edge driver so we these are the drivers we are currently using these are the two classes we are using so if you want to create an object for Chrome driver that I can store in the chromium driver variable or remote
96:15
Speaker A
driver variable or web driver variable because these are all parent classes similarly when you create an object for EDG driver that I can store in the chromium driver aable or remote web driver variable or web driver variable because all three are the parent classes of H so this is the actual
96:31
Speaker A
hierarchy okay but again this web driver is also not a root interface this is also extend from one more interface called search context this is actually root interface in selenium web driver but most of the people don't know this most of the people people will
96:54
Speaker A
say web driver is a root interface from there everything is derived but web driver is also extended interface from search context interface search context is also one interface extend into web driver interface here this is extends and everything is extends extension of the
97:10
Speaker A
classes okay clear everyone so far so this is the basic introduction session for web driver so as part of today's session just try to set up the environment and get ready with them and also try to do this assignment first practice my class example then try to do my class
97:30
Speaker A
assignment same steps only the application has got changed and then tomorrow we will continue rest of the topics right so that's all for today I'll stop here and uh we will continue tomorrow
Topics:Selenium WebDriverJava interfaceChromeDriverFirefoxDriverEdgeDriverRemoteWebDriverSelenium IDESelenium GridAutomation testingWeb application testing

Frequently Asked Questions

What is Selenium WebDriver?

Selenium WebDriver is a Java interface used to automate web applications by controlling browser actions through browser-specific driver classes.

How does WebDriver support multiple browsers?

WebDriver is implemented by the RemoteWebDriver class, which is extended by browser-specific classes like ChromeDriver and FirefoxDriver to handle different browser architectures.

Can you create an object of the WebDriver interface directly?

No, you cannot instantiate the WebDriver interface directly, but you can create a WebDriver variable that holds objects of classes implementing the interface.

Get More with the Söz AI App

Transcribe recordings, audio files, and YouTube videos — with AI summaries, speaker detection, and unlimited transcriptions.

Or transcribe another YouTube video here →