0% found this document useful (0 votes)
15 views11 pages

Different Locators in Selenium

The document outlines various locators used in Selenium, including id, name, className, tagName, linkText, partialLinkText, CSS selector, and Xpath. It provides examples of how to use these locators effectively, including syntax for CSS selectors and XPath expressions. Additionally, it covers advanced CSS selector techniques such as parent-child relationships and sibling selectors.

Uploaded by

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

Different Locators in Selenium

The document outlines various locators used in Selenium, including id, name, className, tagName, linkText, partialLinkText, CSS selector, and Xpath. It provides examples of how to use these locators effectively, including syntax for CSS selectors and XPath expressions. Additionally, it covers advanced CSS selector techniques such as parent-child relationships and sibling selectors.

Uploaded by

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

************************ Different Locators in Selenium ***************************

id, name, className, tagName, linkText, partialLinkText, CSS selector and Xpath

If you are using @locatorName then we have to use = operator and if you are using contains method
then we have to use comma ,
//a[text()='Mobiles']
Name:
Same we can write with ID locator

//input[@id='email']

//button[@type='button' and @class='btn btn-primary' and text()='Primary']

Another example:
//a[text()='HImansu']//parent::td//preceding-sibling::td//div[@class='ui fitted read-only
checkbox']//input[@type='checkbox']

CSS Selectors

1. Id → htmltag#id, #id
2. Class → htmltag.classname, .classname, .classname1.classname2…. classname n
3. Parent > childtag
Contains in CSS
Starting text in CSS

Ending text in CSS


First-of-type in CSS

Last-of-type in CSS
Nth-of-type in CSS

Sibling of element

You might also like