0% found this document useful (0 votes)
19 views6 pages

Locators

Uploaded by

foodavoid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views6 pages

Locators

Uploaded by

foodavoid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

locators?

8types -> static methods -> By class -> abstract class

tagName()
id()
name()
className()
linkText()
partialLinkText()
cssSelector()
xpath()

source code
-------------
<a href="url" id="i1" name="n1" class="c1"> gmail </a>

Locators:
---------
tagName()-> driver.findElement(By.tagName("a"));
id()-> driver.findElement(By.id("i1"));
name()-> driver.findElement(By.name("n1"));
className()-> driver.findElement(By.className("c1"));
linkText()-> driver.findElement(By.linkText("gmail"));
partialLinkText()->driver.findElement(By.partialLinktext("gm"));
cssSelector() -> tag[an = 'av'] - > a[name='n1'], a[id='i1']

xpath: it is nothing but path of an element in html tree structure(webPage)


-----
types:-> absolute and relative
/-> parent to immediate child , //--> parent to any child

xpath by attribute
-------------------
//tag[@an = 'av'] --> //a[@id='i1']

xpath by multiple attribute


----------------------------
//tag[@an='av' and @an='av'] --->//a[@id='i1' and @name='n1']
xpath by text()--> if there is no attributes|if specified expression is
---------------- matching with multiple elements then we use Text()

//tag[text()='tv']-->//a[text()='gmail'] | //a[.='gmail']

xpath by contains()-> to handle partilally dynamic elements


--------------------
//tag[contains(text(),'tv')]--> //a[contains(text(),'il')]

completely dynamic element


---------------------------
dependent independent or xpath by traversing
-> forward traversing-> / or //
-> backward traversing-> /.. (traverse from child to immediate parent)

How to traverse from one child to another child ?


xpath by siblings functions
2types
following sibling--> static/following-sibling::tag[]
preceding sibling--> static/prececding-sibling::tag[]

How to traverse from child to any parent?(ancestor tag)

static/ancestor::tag[]

xpath by grouped index


-----------------------
(xpath expressions)[0]

| and

What is synchronization(waits available in selenium)?


-------------------------
the process of matching selenium speed with an application speed is called as
synchronization.

here we have few types like:

Implicit wait -> driver.manage().timeouts().implicitlyWait().(10,Timeunit


SECONDS);
Explicit wait ,
WebDriverWait class-> Until() -> non static method -> ExpectedConditions->cc-
>conditions->Static method

WebDriverWait ew = new WebDriverWait(driver, 10);


ew.until(ExpectedConditions.elementToBeClickable(''));

How to handle dropdown/ What is Select class?

To handle the drop down we use select class....(it is to handle dropdown)

Select class is a concrete class which consist of parameterised constructor which


takes single arguments,that is address of the dropdown....
It is imported from ui package

Types of dropdown:- two type -> Single select and multi select dropdown

Sytax:- Select sel = new Select(element);

How to mouse actions/ What is Actions class?

To handle the mouse actions we use Actions class....

Actions class is a concrete class which consist of parameterised constructor which


takes single arguments, that is address of the browser(driver)....
it is imported from interactions package
perform() is mandatory

Types of mouse actions:- right click -> contextClick(),


left click -> click() , //no actions class is required
double click -> doubleCLick(),
drag and drop-> dragAndDrop(),
mouse hover-> moveToElement()

Syntax:- Actions Act = new Actions(driver);


Frameworks?
----------
1.TestNG->TestNewGeneration/TestNextGeneration
2.POM-> Page Object Model
3.DDT-> Data Driven Testing
4.MDT-> Method Driven Testing

TestNG(test new/next generation)


--------------------------------------
It is a unit testing framework which is used by
developers in order to perform wbt,
In automation testing we use TestNG because:
1.We can perform verification
2.We can generate reports
3.We can achieve parallel execution ->T1-> chrome and Firefox
4.we can have multiple script execution -> t1 and t2

important annotations of testNG


--------------------------------
@beforeSuite @dataprovider
@beforeTest @parameter
@beforeClass @findBy
@beforeMethod
@test
@afterMethod
@afterClass
@afterTest
@afterSuite

POM?
it is a framework which is of java designed pattern mainly used to handle
staleElementReferenceException.

IN pom we use @findBy instead of findElement(),


because @findBy will always fetch updated address
of an element

3 stages:
declaration
initialization
utilization

What is DataDrivenTesting?

It is a framework which is used to test an application for multiple testdata


(testdata stored in excel)

Here we use Apache POI file for DDT.


what is method driven testing?
It is nothing but the methods which are created
in pom class to perform action on the elements

how to change or switch between one tab to another tab?

We use driver.switchTo().window(pass address of the tab); and pass address of the


tab or browser

To get address of the browsers we use getWindowHandle() and getWindowHandles()

getWindowHandle()-> it will fetch address of the parent browser or tab address


getWindowHandles()-> it will fetch address of both parent and all the child browser
or tabs address

You might also like