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"
Sur cette page du site, vous pouvez voir la vidéo en ligne Selenium Tutorial Locator - Part II | XPath-CSS Selector Locator Tutorial | by IT Industry Tutorials durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Arun Kapoor 10 mai 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 221 fois et il a aimé 16 téléspectateurs. Bon visionnage!