0% found this document useful (0 votes)
6 views2 pages

Day22 Locators

The document discusses the use of locators to identify web elements uniquely on a webpage, including various types such as id, name, and linkText, as well as customized locators like CssSelector and XPath. It outlines scenarios for using findElement() and findElements() methods, detailing their return types based on whether they match single or multiple elements or none at all. Additionally, it includes an assignment to interact with a web application by counting links and images and clicking on links using different locator types.

Uploaded by

ϻohammed Ali
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)
6 views2 pages

Day22 Locators

The document discusses the use of locators to identify web elements uniquely on a webpage, including various types such as id, name, and linkText, as well as customized locators like CssSelector and XPath. It outlines scenarios for using findElement() and findElements() methods, detailing their return types based on whether they match single or multiple elements or none at all. Additionally, it includes an assignment to interact with a web application by counting links and images and clicking on links using different locator types.

Uploaded by

ϻohammed Ali
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

Day 22

------
Locators
we can identify various elements on the web using Locators

Locators are addressed that identifya web element uniquely within the page.
------------
1. id
2. name
3. linkText
4. PartialLinkText

5 className
6. tagName

customized Locators
--------------------
1. CssSelector
[tag and Id]
[tag and class]
[tag and attribute]
[tag , class and attribute]

2. XPath
absolute xPath
Relative XPath

[Link](By.).action();

Tablets Table - PartialLinkText()


Submit Send - LinkText()

findElement() ---single webelement


findElements() ---multiple webelements

scanario 1: Locators mathing with single web element


findElement(Loc) --------->Signle web element return type ---> WebElement
findElements(Loc) --------->Signle web element return type ---> List<WebElement>

Sceanario 2: Locator is matching with multi web elements


findElement(Loc) --------->first web element return type ---> WebElement
findElements(Loc) --------->multiple web element return type --->
List<WebElement>

Scenario 3: Lo is not matching with any element/s


findElement(Loc) --------->No Such Element Exception return type --->
WebElement
findElements(Loc) --------->returns '0' [empty list] return type --->
List<WebElement>

Assignment

open application '[Link]/[Link]'


1. Total no. of links
2. Totla number of images
3. Click on Any link usng LinkText and PartialLinkText

You might also like