Selenium Tutorial Locator - Part II | XPath-CSS Selector Locator Tutorial | by IT Industry Tutorials

Published: 10 May 2020
on channel: Arun Kapoor
221
16

Locators Part II:

XPath - XPath is the language used when locating XML (Extensible Markup Language) nodes.
Since HTML can be thought of as an implementation of XML,
we can also use XPath in locating HTML elements.
Advantage: It can access almost any element, even those without class, name, or id attributes.
Disadvantage: It is the most complicated method of identifying elements
because of too many different rules and considerations.

//*[@id="username"]

Syntax:

//tagName[@attribute='value']

tagName= input
attribute= id
value= username

//input[@id='username']

CSS Selector - CSS Selectors are string patterns used to identify an element
based on a combination of HTML tag, id, class, and attributes.
Locating by CSS Selector is more complicated than the previous methods,
but it is the most common locating strategy of advanced Selenium users because
it can access even those elements that have no ID or name.

CSS Selectors have many formats, but we will only focus on the most common ones.

Syntax:

tagName[attribute='value']

input[id='password']

Some Important Interview Questions for Selenium WebDriver:
1. How to copy XPath using Browser.
2. How to Create Customized XPath and CSS.
3. How to Verify those XPath and CSS using Console.

Additional:
ChroPath Plugin Introduction and How to use it for creating Xpath and CSS


Thanks,
IT Industry Tutorials
it industry tutorials
itindustrytutorials
"IT Industry Tutorials" "IT IndustryTutorials" "ITIndustry Tutorials" ITIndustryTutorials itindustrytutorials ITindustrytutorials ittutorials "IT Tutorials" "IT tutorials"


On this page of the site you can watch the video online Selenium Tutorial Locator - Part II | XPath-CSS Selector Locator Tutorial | by IT Industry Tutorials with a duration of hours minute second in good quality, which was uploaded by the user Arun Kapoor 10 May 2020, share the link with friends and acquaintances, this video has already been watched 221 times on youtube and it was liked by 16 viewers. Enjoy your viewing!