Sunteți pe pagina 1din 15

Selenium Basics

What is selenium ? how its work ?what is basic features of selenium ?why we use selenium?

Selenium is not a tool is available in library(jar is kind of library and we use this jar)under this jars there
is number of methods classes are given to us, among this we have one interface called as "webdriver
interface" and what interface to it is used to define some rules(means only method declaration there is
no method body)there is different drivers are available for different browsers and this are in form of
classes,so all these different classes are implementing webdriver interface.so what will they do they
implement the method define in the webdriver interface according to there business logic.so they
override the all method in webdriver

So the script is same but initialization part is different

How to use?1. I create a main method 2. I need a driver so I create a object of webdriver but we can'nt
create a object of webdriver 3.so to access webdriver we will use topcasting webdriver driver = new
chromedriver();

1 we create a reference of webdriver interface and point to this to chromedriver object so we can access
chromedriver

To create selenium project -go to file > new >project >maven project >and create one maven project

There is 2 main folder –src/main/java and src/test/java

src/main/java- its used to design some core features mean any kind of utility-page classes,libraries we
write under main java

src/test/java-testing framework such as testing,junit we write under test java


Session id null
82bb26da68a2a4065e39d6f3c2334638

SID
1.webdriver dr = new Browser
chromedriver();
Its act like server
2.louch google .com
chromedriver
3.get.title

Script

4.Quit

5.again –get.title
Session 3

Locator Concept

There are 8 different locator in selenium


All the field such as text field ,simple text, checkbox, logo, links, button we called as the web element
because all this are available on webpage that why called them as web-element

How to create webelement?

With the help of different locators we can create a web element. ---

Find element is an method and By is an class here its gives u webelement referance so we can store it
into web element
Find.element is giving us a web element so we create a reference of it and create a weblement
Second method is Reusable we can use whenever we needed

2.locator –Name

3.locator-xpath
Locator-Css
Locator – class
Locator-link text
Locator- Partial link text
Locator Tag
3rd method we are actually using for locators

-----1.here By is class so we can use it directly ---By.id is a method----and id is form of locator

Id is returns by class So we can store into the By class reference

And perform a action

S-ar putea să vă placă și