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

Locators

The document provides an overview of various methods for locating elements in web development, specifically using Xpath and CSS selectors. It includes syntax examples for both Xpath and CSS, detailing how to select elements based on attributes, tag names, and text values. Additionally, it demonstrates the use of relative and absolute Xpath expressions for element identification.

Uploaded by

abhimanyu thakur
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)
74 views2 pages

Locators

The document provides an overview of various methods for locating elements in web development, specifically using Xpath and CSS selectors. It includes syntax examples for both Xpath and CSS, detailing how to select elements based on attributes, tag names, and text values. Additionally, it demonstrates the use of relative and absolute Xpath expressions for element identification.

Uploaded by

abhimanyu thakur
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

id

name
cssSelector
Xpath
className
tagName
linkText
partialLinkText

Xpath - Firebug and Firepath - Chropath


-----------
<input type="email" class="whsOnd zHQkBf" jsname="YPqjbf" autocomplete="username"
spellcheck="false" tabindex="0" aria-label="Email or phone" name="identifier"
autocapitalize="none" id="identifierId" dir="ltr" data-initial-dir="ltr" data-
initial-value="" badinput="false">

//tagName[@attribute='value'] - Relative Xpath, Absolute xpath, partial xpath

//input[@name='identifier'][@id='identifierId']

//input[@name='identifier' and @id='identifierId']

//input[@id='identifierId']

//*[@id="identifierId"]
//*[@id="identifierId"]

//input[@name='q']

//*[@id="view_container"]/div/div/div[2]/div/div[1]/div/form/content/section/div/
content/div[1]/div/div[1]/div/div[1]

//html/

<input type="submit" class="button" value="Submit">


<input type="submit" class="button" value="Submit">`

XPATH SYNTAX
-----------------
//tagName[@attribute='value']
//tagName[@attribute='value'][@attribute='value'][@attribute='value']
//tagName[starts-with(@attribute,'value')]
//tagName[contains(@attribute,'value')]
//tagName[text()='value']
//tagName[contains(text(),'partialvalue')]
//tagName[@attribute='value']/..
//tagName[@attribute='value']/parent::tagname
//tagName[@attribute='value']/following-sibling::tagname
//tagName[@attribute='value']/preceding-sibling::tagname[1]

CSS SYNTAX
-------------------
input[id='identifierId']
input[id='identifierId'][type='email']
input[id^='identifie'] - starts-with
input[id$='tifierId'] - ends-with
input[id*='tifier'] - contains
#identifierId - id
tagName - tagName
.Xb9hP - className
input#[Link][type='email']
[Link] > div > div:first-child
[Link] > div > div:last-child
[Link] > div > div:nth-child(2)
div[jsname='dWPKW'] > div > div > div > div:nth-child(2)

You might also like