Introduction to Selenium WebDriver
Selenium WebDriver is a core component of the Selenium suite, designed to automate web applications across different browsers. It is:
- A Java interface defining methods for browser automation.
- Implemented by classes like ChromeDriver, FirefoxDriver, and EdgeDriver, each tailored to specific browser architectures.
- An API (Application Programming Interface) acting as an intermediary between the Java client code and the browser.
WebDriver Architecture
- WebDriver Interface: Defines abstract, public, and static methods.
- RemoteWebDriver Class: Implements the WebDriver interface and serves as a parent class.
- Browser-specific Drivers: ChromeDriver, FirefoxDriver, EdgeDriver extend RemoteWebDriver, implementing browser-specific logic.
Understanding WebDriver as an API
WebDriver functions as an API by:
- Receiving method calls from Java client programs.
- Translating these calls into browser actions via protocols (W3C protocol in Selenium 4+).
- Acting as a bridge between the client (Java code) and the browser, enabling automation without direct browser manipulation.
Selenium WebDriver Environment Setup
Two main approaches to set up Selenium WebDriver in Java projects:
1. Manual Setup
- Download Selenium WebDriver JAR files from the official Selenium website.
- Extract the ZIP file containing multiple JARs.
- Create a Java project in Eclipse.
- Attach all extracted JAR files to the project's build path manually.
- Drawbacks: Manual updates required for new Selenium versions, time-consuming.
2. Maven Project Setup (Recommended)
- Create a Maven project in Eclipse (default support in Eclipse and IntelliJ).
- Add Selenium WebDriver dependency in the
pom.xmlfile using the Maven Central repository snippet. - Maven automatically downloads and manages all required JAR files.
- Easy to update Selenium versions by changing the version number in
pom.xml.
Writing a Basic Automation Test Case
Test Case Steps:
- Launch Chrome browser.
- Open a specified URL.
- Verify the page title matches the expected title.
- Close the browser.
Implementation Highlights:
- Instantiate the browser driver (e.g.,
WebDriver driver = new ChromeDriver();). - Use
driver.get(URL)to open the web page. - Retrieve the page title with
driver.getTitle(). - Compare actual and expected titles using
String.equals(). - Close the browser using
driver.close()ordriver.quit().
Browser Flexibility
- Change the browser by instantiating the corresponding driver class (e.g.,
new EdgeDriver(),new FirefoxDriver()). - Ensure the respective browsers are installed on the system.
Locating and Interacting with Web Elements
- Web elements include input boxes, buttons, links, images, checkboxes, dropdowns, etc.
- Each element has attributes (id, name, class, etc.) used to locate it uniquely.
- Selenium provides various locator strategies (ID, name, XPath, CSS selectors).
- Actions on elements include clicking, sending text (
sendKeys), selecting options, etc. - Element identification and interaction are critical and will be covered in upcoming sessions.
Additional Notes
- Selenium 4 introduced the ChromiumDriver class between RemoteWebDriver and browser-specific drivers for Chrome and Edge.
- WebDriver extends from the SearchContext interface, which is the root interface in Selenium.
- Maven is widely used in real-time projects for dependency management and build automation.
Next Steps
- Practice setting up the Maven project and running the basic test case.
- Prepare for upcoming lessons on element locators and advanced WebDriver methods.
This tutorial provides a solid foundation for beginners to start automating web applications using Selenium WebDriver with Java, emphasizing best practices in environment setup and test case development.
For further learning, check out our Exploring Puppeteer and Headless Browsers: A Comprehensive Guide for insights into browser automation alternatives. Additionally, if you're interested in Java programming, our Java Programming Course: Introduction, Structure, and Setup Guide can help you get started with the language.
so from today we are going
to start uh selenium web driver so first let us see the introduction
like what is selenium web driver and what it is contains and then we will see how we can
set up environment and after that we'll see
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
component in selenium web driver is a one of
the component in selenium so selenium contains the three components one is selenium ID selenium
web driver selenium grd so these are the three components which we can call them as a selenium
suit and web driver is a one of a component in
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
an interface in Java interface interface is a
blueprint of class which contains a public and static variables and which contains a default
method public methods abstract methods and if there is an interface that should be implemented
by using a class right there should be some class
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
classes like Chrome driver class or Internet
Explorer class Firefox browser class because when I say when I talk about web application so
people can access web application in different browsers some people will use Chrome some some of
them will use Firefox and some other browsers so
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
methods by using Chrome driver class and these
implementations Works only for Chrome browser it cannot use for any other browser because
the browser sub browser internal architecture will be different even the purpose or goal of the
browser is same but internally the implementation
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
is implemented all the methods from web driver
interface and similarly there is another class called Firefox driver class and this class is
implemented again same web driver interface according to Firefox browser architecture so like
this how many browsers are in the market like this
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
remote web driver class so actually web driver
interface is implemented directly by remote web driver class and this remote web driver class
implemented extends again into Chrome Driver F firef Fox Hedge so these are the extended classes
from remote web driver class okay web driver is
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
public method abstract methods and so on and again
the web driver interface is implemented by remote web driver class one single class and this again
remote web driver class again extends into Chrome driver Firefox driver and H driver now these three
are the child classes of remote web driver class
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 classes and we can also consider web driver is
also parent parent of parent suppose if I create
an object for Chrome driver or Firefox or Edge
driver can we hold that object in the remote web driver class yes or no can we hold that object in
the remote web driver class object yes similarly 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 this is most important point right next one web
driver is an API application programming interface
this is the third definition web driver is a an
API so to understand this we need to 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 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 we need to divide these three terms and then
we need to understand application programming
in interface okay these are three terms we need
to understand so let me explain what exactly it is just a moment yeah so application programming
uh interface so normally if you take
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 front end application server or we can say web
server or web layer and database so these are the three parts are there for if you take
any web based applications okay so what is
front end application means this is also called
presentation layer because user will directly 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 you are doing on the browser level that is all
comes under user actions or user interactions 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 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 is also called application layer or we can say
web server multiple names are there and this is a mediate tree between the presentation layer
and the database layer so what is the purpose
of this layer is and what this layer basically
contains is a business logic actual programming 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 you click on the submit button or when you're
browsing the data basically what happens is one request will go to the server okay one request
user request will go to the server and when I
hit the server in the business logic there are n
number of apis are there apis apis in the sense 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 of requests are there we have something called
get request okay and then we have a put request we have a delete request so like this we have
a multiple type of request we will send and it
will hit to the particular API so what type of
request we are sending from here corresponding 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 request to the database layer and API will receive
the request here from the business logic layer and then according to the request it will send to the
database layer now in the database layer the data
will be fited whatever the request we have sent
corresponding data will be fetched and again it 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 have to provide some input and it will give the
response okay it will request take the request and provide the response to the user so from the
user it will take the request and to the user it
will provide the response that is the purpose of
an APM simple example I'll tell you to understand 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 so in between these two there will be one person
right we will order our food to that person and what he will do he will go to the kitchen again
the food will be prepared here and get the food
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 talking about only apis okay so microservices will
be used to interact between multiple apis again so
each and every API will have some communication
so API to API so they exactly microservices come into picture but here I'm talking about only apis
okay right so this is how we can understand what 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 API contains some programming code so it is a
programming and it is acting as an interface
between our presentation layer and database layer
so it is an interface and also it is assisting to the application right why we have created an
API because from the application we are sending 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 a programming and also acting as an interface so
it is an interface combinely we can call it as a
application programming and interface this is how
the name comes application programming interface API so everybody's understood now what is an APA
is a very basic concept I have explained and if 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 say when you do automation like what are the
main components which we have is browser the
first main component is what browser let's say
this is my browser understand very carefully so this is my browser and web driver where web
driver will sit into so web driver will be 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 class again extend into multiple classes basically
what is a class contains so many methods when you
call those methods it will perform certain tasks
so web driver contains so many number of methods by calling these methods we will try to automate
the web application so each method is having their 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 trying to invoke in the web driver methods or we
are trying to call the web driver methods and web
driver methods will ually perform the task on the
browser like it will open the URL automatically and it will enter the input some input in the
input box it will perform the click action on the 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 those methods web driver methods and web driver
methods will perform the task on the browser okay
but again this how this web driver will interact
with the browser internally there are certain Protocols are there okay previously there is Json
protocol they are trying to use but from java 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 other one is our Java code which is a client
actually so what web driver method is doing which
is do which is calling by Java that means when I
call this method sometimes we can pass parameters sometimes may not require any parameters so
basically who is invoking this method is Java and 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 is exactly working here so that is the reason web
driver is acting as a API application programming
and interface so here see AP in the sense there
no need to be have any data database mainly three layers should be there it can be any type of layer
okay here we do not have any database here we do 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 here got my point when you call this web driver
method and what web driver method will do it will
perform the action on the browser so we can see
those actions on the browser sometimes we will capture some information from the browser also
for example the title of the web page and whatever 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 programming and interface there no need to be any
database here APA means it works not only based
on the database here there is no database concept
guys I don't know why you asking database did I tell you anything about the database here nothing
it is just Java client web driver method and then 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 method will actually do the actions on the browser
that's how it will work okay so here there is no
database nothing but actually in the real time APS
if you're directly working with APS there should be some database there should be web server
there should be client so here the apas will 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 in this also actual data will be presented in
the database here actions will be performed on
the browser okay this is a similarity this is
a comparison so you don't need to have exact component here here database is there but here we
don't have database instead we have a browser so 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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
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
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
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
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
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
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 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 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 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 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 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 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 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 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 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
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
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
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 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 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 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 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 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 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 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 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 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 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 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 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 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
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
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 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 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 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 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
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
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 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 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
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
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
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
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 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 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 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 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 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 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 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 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 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 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
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
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
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
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 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 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
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 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 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. 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 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 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 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 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 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 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 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 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 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 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 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 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 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 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 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
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
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
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
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
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 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 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 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 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
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
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
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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
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
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
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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
Selenium WebDriver is a tool designed for automating web applications across various browsers. It acts as an API that translates method calls from Java client programs into browser actions, allowing for seamless automation without direct manipulation of the browser.
You can set up Selenium WebDriver in a Java project either manually or using Maven. The manual setup involves downloading JAR files and attaching them to your project, while the Maven setup is recommended as it automatically manages dependencies and updates through the pom.xml file.
To write a basic automation test case, you need to launch a browser, open a specified URL, verify the page title, and then close the browser. For example, you can instantiate a ChromeDriver, use driver.get(URL) to navigate, and check the title with driver.getTitle().
Selenium provides several strategies for locating web elements, including by ID, name, XPath, and CSS selectors. Each element can be interacted with through actions like clicking or sending text, which are essential for effective automation.
Using Maven for Selenium WebDriver projects simplifies dependency management and project setup. It automatically downloads required JAR files and makes it easy to update Selenium versions by modifying the pom.xml file, saving time and reducing manual errors.
Yes, Selenium WebDriver supports multiple browsers. You can switch between browsers by instantiating the corresponding driver class, such as new ChromeDriver(), new FirefoxDriver(), or new EdgeDriver(), provided the respective browsers are installed on your system.
After mastering the basics, you should practice setting up a Maven project and running test cases. Additionally, prepare for more advanced topics such as element locators and WebDriver methods to enhance your automation skills.
Heads up!
This summary and transcript were automatically generated using AI with the Free YouTube Transcript Summary Tool by LunaNotes.
Generate a summary for freeRelated Summaries
Exploring Puppeteer and Headless Browsers: A Comprehensive Guide
This video provides an in-depth look at Puppeteer, a powerful Node.js library for controlling headless browsers. Learn about the installation process, basic commands, and advanced features such as web scraping, automated testing, and image downloading.
Java Programming Course: Introduction, Structure, and Setup Guide
Learn about Java programming fundamentals, data structures, and how to set up your coding environment.
Java Programming: A Comprehensive Guide to Understanding Java and Its Concepts
Explore Java programming concepts including OOP, exception handling, and collections. Learn how to build robust applications!
Java Course Introduction: Mastering Coding Fundamentals and Data Structures
Kickstart your Java programming journey with our guided course covering basics to algorithms for aspiring developers.
Comprehensive Guide to HTML and CSS: From Basics to Advanced Techniques
This video series provides a thorough introduction to HTML and CSS, covering everything from the foundational elements of web development to advanced styling techniques. Learn how to create structured web pages, style them effectively, and implement interactive features using HTML and CSS.
Most Viewed Summaries
Kolonyalismo at Imperyalismo: Ang Kasaysayan ng Pagsakop sa Pilipinas
Tuklasin ang kasaysayan ng kolonyalismo at imperyalismo sa Pilipinas sa pamamagitan ni Ferdinand Magellan.
A Comprehensive Guide to Using Stable Diffusion Forge UI
Explore the Stable Diffusion Forge UI, customizable settings, models, and more to enhance your image generation experience.
Pamamaraan at Patakarang Kolonyal ng mga Espanyol sa Pilipinas
Tuklasin ang mga pamamaraan at patakaran ng mga Espanyol sa Pilipinas, at ang epekto nito sa mga Pilipino.
Mastering Inpainting with Stable Diffusion: Fix Mistakes and Enhance Your Images
Learn to fix mistakes and enhance images with Stable Diffusion's inpainting features effectively.
Pamaraan at Patakarang Kolonyal ng mga Espanyol sa Pilipinas
Tuklasin ang mga pamamaraan at patakarang kolonyal ng mga Espanyol sa Pilipinas at ang mga epekto nito sa mga Pilipino.

