SlideShare a Scribd company logo
Page 0Classification: Restricted
Selenium Training
Object Identification
Page 1Classification: Restricted
Agenda
• Object Identification in IDE
• Multi Browser Testing
• Locating by Identifier
• Locating by ID
• Locating by Name
• Locating by Xpath
• Locating by Xpath
• Locating hyperlinks by link text
• Locating by CSS Selector
• Hierarchy for locating elements
• Classroom Exercises
Page 2Classification: Restricted
Object Identification in IDE
• For many Selenium commands, a target is required.
• This target identifies an element in the content of the web application, and
consists of the location strategy followed by the location in the format
locatorType=location.
• The locator type can be omitted in many cases.
• There are different ways of locating the elements on a web page in
Selenium
Page 3Classification: Restricted
 FF Developer tools: https://developer.mozilla.org/en-US/docs/Tools
• Firebug: Install from http://getfirebug.com
 IE Developer Tools: http://www.microsoft.com/en-
us/download/details.aspx?id=18359
 Chrome Developer tools:
https://developers.google.com/chrome-developer-tools/docs/overview
 Safari Developer Tools:
https://developer.apple.com/technologies/safari/developer-tools.html
Multi Browser Testing
Page 4Classification: Restricted
Locating by Identifier
• The most common method of locating.
• The first element with the id attribute value matching the location will be
used.
• If no element has a matching id attribute, then the first element with a
name attribute matching the location will be used.
• For instance, your page source could have id and name attributes as
follows:
Page 5Classification: Restricted
Locating by ID
•The Id strategy looks for an element in the page having an id attribute
corresponding to the specified pattern
Page 6Classification: Restricted
Locating by Name
• The name locator type will locate the first element with a matching name
attribute.
• If multiple elements have the same value for a name attribute, then you
can use filters to further refine your location strategy.
• The default filter type is value (matching the value attribute).
Page 7Classification: Restricted
Locating by Xpath
• XPath is the language used for locating nodes in an XML document.
• As HTML can be an implementation of XML (XHTML), Selenium users can
leverage this powerful language to target elements in their web
applications.
• One of the main reasons for using XPath is when you don’t have a suitable
id or name attribute for the element you wish to locate.
• You can use XPath to either locate the element in absolute terms (not
advised), or relative to an element that does have an id or name attribute.
• XPath locators can also be used to specify elements via attributes other
than id and name.
Page 8Classification: Restricted
Locating by Xpath
• Syntax:
• //tagname[@property type=’property value’]
Page 9Classification: Restricted
Locating hyperlinks by link text
• This strategy is intended to select links only and selects the anchor element
containing the specified text:link=The text of the link
• This is a simple method of locating a hyperlink in your web page by using
the text of the link.
• If two links with the same text are present, then the first match will be
used.
Page 10Classification: Restricted
Locating by CSS Selector
• CSS(CascadingStyleSheets) is a language for describing the rendering of
HTML and XML documents.
• CSS uses Selectors for binding style properties to elements in the
document.
• CSS Selectors are string patterns used to identify an element based on a
combination of HTML tag, id, class, and attributes.
• CSS Selectors have many formats, but we will only focus on the most
common ones.
• Tag and ID
• Tag and class
• Tag and attribute
• Tag, class, and attribute
• Inner text
Page 11Classification: Restricted
Locating by CSS Selector
Page 12Classification: Restricted
Hierarchy for locating elements
• ID
• Name
• Xpath
• LinkText
• CSS
Page 13Classification: Restricted
Classroom Exercises
• Write the selenese code for the following steps by using different locators.
• Navigate to https://www.google.co.in/
• Search for “Selenium locators”
• Navigate to the first link in the returned result
Page 14Classification: Restricted
Thank You!

More Related Content

PPTX
PPTX
An introduction to Metadata Application Profiles
PDF
Basic-CSS-tutorial
PPT
Content Strategy for WordPress
PPTX
presentation in html,css,javascript
PPT
An Introduction to CSS
PDF
Emilie Boillat - Whatchamacallit: Controlled Vocabularies for Technical Write...
An introduction to Metadata Application Profiles
Basic-CSS-tutorial
Content Strategy for WordPress
presentation in html,css,javascript
An Introduction to CSS
Emilie Boillat - Whatchamacallit: Controlled Vocabularies for Technical Write...

What's hot (18)

PDF
Whatchamacallit: Controlled Vocabularies for Technical Writers (soap! 2015)
PPTX
Encoding Schemes
PDF
XML Information set
PPT
Content Strategy for WordPress: Case Study
PPTX
FFW Gabrovo PMG - JavaScript 1
PPT
Introduction to XML
PPT
Website with HTML CSS
PPTX
PPTX
FFW Gabrovo PMG - jQuery
PPTX
Languages for web(HTML,CSS,JS)
PPTX
FFW Gabrovo PMG - HTML
PPTX
MTA css flow, positioning, and styling
PPT
Css present
PPTX
Managing Applications in CodeIgniter
PPT
Cascading Style Sheets(CSS)
PPTX
Css presentation lecture 1
PPTX
Css part 1
Whatchamacallit: Controlled Vocabularies for Technical Writers (soap! 2015)
Encoding Schemes
XML Information set
Content Strategy for WordPress: Case Study
FFW Gabrovo PMG - JavaScript 1
Introduction to XML
Website with HTML CSS
FFW Gabrovo PMG - jQuery
Languages for web(HTML,CSS,JS)
FFW Gabrovo PMG - HTML
MTA css flow, positioning, and styling
Css present
Managing Applications in CodeIgniter
Cascading Style Sheets(CSS)
Css presentation lecture 1
Css part 1
Ad

Similar to Session 02 - Object Identification - Part 1 (20)

PPSX
Selenium WebDriver with Java
PPTX
Automatedtestingwithselenium shubham jain
PPTX
Agile_unit_2_newdddcdcdscdssvvdvdsvdsv.pptx
PPTX
Agile_unit_2_newdddcdcdscdssvvdvdsvdsv.pptx
PPTX
Automated_Testing_Selenium
PPT
Web testing with selenium and by quontra solutions
PDF
How to use selenium locators effectively for web automation.pdf
PPTX
Automation Testing by Selenium Web Driver
PPTX
Selenium training
PDF
Selenium Overview
PDF
Hands-on Guide to Object Identification
PPTX
Locators and webdriver commands Selenium Session2.pptx
PDF
Introduction to Selenium and Test Automation
PPTX
Selenium-Locators
PPTX
Selenium WebDriver training
PDF
Understanding CSS Selectors in Selenium.pdf
PDF
Efficient Rails Test-Driven Development - Week 6
PDF
2010 07-18.wa.rails tdd-6
PDF
Selenium bootcamp slides
PPTX
TApp Documentation
Selenium WebDriver with Java
Automatedtestingwithselenium shubham jain
Agile_unit_2_newdddcdcdscdssvvdvdsvdsv.pptx
Agile_unit_2_newdddcdcdscdssvvdvdsvdsv.pptx
Automated_Testing_Selenium
Web testing with selenium and by quontra solutions
How to use selenium locators effectively for web automation.pdf
Automation Testing by Selenium Web Driver
Selenium training
Selenium Overview
Hands-on Guide to Object Identification
Locators and webdriver commands Selenium Session2.pptx
Introduction to Selenium and Test Automation
Selenium-Locators
Selenium WebDriver training
Understanding CSS Selectors in Selenium.pdf
Efficient Rails Test-Driven Development - Week 6
2010 07-18.wa.rails tdd-6
Selenium bootcamp slides
TApp Documentation
Ad

More from SiddharthSelenium (9)

PPTX
Session 09 - OOPS
PPTX
Session 08 - Arrays and Methods
PPTX
Session 07 - Flow Control Statements
PPTX
Session 06 - Java Basics
PPTX
Session 05 - Introduction to WebDriver - Part 02
PPTX
Session 04 - Creating Test Suites in IDE
PPTX
Session 02 - Selenium IDE - Part 2
PPTX
Session 01 - Introduction to Selenium - Part 2
PPTX
Session 01 - Introduction to Automation - Part 1
Session 09 - OOPS
Session 08 - Arrays and Methods
Session 07 - Flow Control Statements
Session 06 - Java Basics
Session 05 - Introduction to WebDriver - Part 02
Session 04 - Creating Test Suites in IDE
Session 02 - Selenium IDE - Part 2
Session 01 - Introduction to Selenium - Part 2
Session 01 - Introduction to Automation - Part 1

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PPT
Teaching material agriculture food technology
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
MIND Revenue Release Quarter 2 2025 Press Release
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
KodekX | Application Modernization Development
Encapsulation theory and applications.pdf
Teaching material agriculture food technology
The Rise and Fall of 3GPP – Time for a Sabbatical?
Understanding_Digital_Forensics_Presentation.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Encapsulation_ Review paper, used for researhc scholars
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Big Data Technologies - Introduction.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Machine learning based COVID-19 study performance prediction
Programs and apps: productivity, graphics, security and other tools
Unlocking AI with Model Context Protocol (MCP)
Building Integrated photovoltaic BIPV_UPV.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
MIND Revenue Release Quarter 2 2025 Press Release
The AUB Centre for AI in Media Proposal.docx
KodekX | Application Modernization Development

Session 02 - Object Identification - Part 1

  • 1. Page 0Classification: Restricted Selenium Training Object Identification
  • 2. Page 1Classification: Restricted Agenda • Object Identification in IDE • Multi Browser Testing • Locating by Identifier • Locating by ID • Locating by Name • Locating by Xpath • Locating by Xpath • Locating hyperlinks by link text • Locating by CSS Selector • Hierarchy for locating elements • Classroom Exercises
  • 3. Page 2Classification: Restricted Object Identification in IDE • For many Selenium commands, a target is required. • This target identifies an element in the content of the web application, and consists of the location strategy followed by the location in the format locatorType=location. • The locator type can be omitted in many cases. • There are different ways of locating the elements on a web page in Selenium
  • 4. Page 3Classification: Restricted  FF Developer tools: https://developer.mozilla.org/en-US/docs/Tools • Firebug: Install from http://getfirebug.com  IE Developer Tools: http://www.microsoft.com/en- us/download/details.aspx?id=18359  Chrome Developer tools: https://developers.google.com/chrome-developer-tools/docs/overview  Safari Developer Tools: https://developer.apple.com/technologies/safari/developer-tools.html Multi Browser Testing
  • 5. Page 4Classification: Restricted Locating by Identifier • The most common method of locating. • The first element with the id attribute value matching the location will be used. • If no element has a matching id attribute, then the first element with a name attribute matching the location will be used. • For instance, your page source could have id and name attributes as follows:
  • 6. Page 5Classification: Restricted Locating by ID •The Id strategy looks for an element in the page having an id attribute corresponding to the specified pattern
  • 7. Page 6Classification: Restricted Locating by Name • The name locator type will locate the first element with a matching name attribute. • If multiple elements have the same value for a name attribute, then you can use filters to further refine your location strategy. • The default filter type is value (matching the value attribute).
  • 8. Page 7Classification: Restricted Locating by Xpath • XPath is the language used for locating nodes in an XML document. • As HTML can be an implementation of XML (XHTML), Selenium users can leverage this powerful language to target elements in their web applications. • One of the main reasons for using XPath is when you don’t have a suitable id or name attribute for the element you wish to locate. • You can use XPath to either locate the element in absolute terms (not advised), or relative to an element that does have an id or name attribute. • XPath locators can also be used to specify elements via attributes other than id and name.
  • 9. Page 8Classification: Restricted Locating by Xpath • Syntax: • //tagname[@property type=’property value’]
  • 10. Page 9Classification: Restricted Locating hyperlinks by link text • This strategy is intended to select links only and selects the anchor element containing the specified text:link=The text of the link • This is a simple method of locating a hyperlink in your web page by using the text of the link. • If two links with the same text are present, then the first match will be used.
  • 11. Page 10Classification: Restricted Locating by CSS Selector • CSS(CascadingStyleSheets) is a language for describing the rendering of HTML and XML documents. • CSS uses Selectors for binding style properties to elements in the document. • CSS Selectors are string patterns used to identify an element based on a combination of HTML tag, id, class, and attributes. • CSS Selectors have many formats, but we will only focus on the most common ones. • Tag and ID • Tag and class • Tag and attribute • Tag, class, and attribute • Inner text
  • 13. Page 12Classification: Restricted Hierarchy for locating elements • ID • Name • Xpath • LinkText • CSS
  • 14. Page 13Classification: Restricted Classroom Exercises • Write the selenese code for the following steps by using different locators. • Navigate to https://www.google.co.in/ • Search for “Selenium locators” • Navigate to the first link in the returned result