SlideShare a Scribd company logo
1 of 17
Download to read offline
Hands-on guide to
Object Identification
Speaker : Dharmesh Vaya
Presented On : 24.06.2016
Twitter : @DRVaya
Web : http://drvaya.wordpress.com/
Test Automation Consultant with 10+ yrs experience
Expertise with designing/development of Selenium
based Automation frameworks (as well as other tools)
Speaker at various forums - Google DevFests, Selenium
Conference
Trainer/Mentor - to different MNCs/Startups.
Dharmesh Vaya
a.k.a.
Dharam
Agenda
★ Basics of Object Identification
★ What are CSS Selectors/Locator’s ?
★ What are Xpath Locators ?
★ Let’s go advanced …
★ Cheat Sheet
★ Best Practices from experience
Basics of
Object Identification
Approach ...
★ More than locators you need to understand the underlying
Web development techniques.
★ Carefully understand the page source and identify the libraries
used. This will help in building robust scripts.
★ Using Firebug/Developer tools.
★ Test your element even before you do it with Selenium.
(Developer toolbars are meant for that).
★ Ultimately, Locators come first, Logic is secondary and will be
built upon the locators.
What are
CSS Selectors/Locator’s?
CSS Selectors...
★ Absolute Selectors
World -> Continent -> Country -> State -> City -> Street
★ Relative Selectors
Street Number or House Number
★ Class or ID based Selectors
★ Finding using other attributes
★ Partial Matching
What are
Xpath Locator’s ?
Xpath Locators...
★ Absolute Xpath
World -> Continent -> Country -> State -> City -> Street
★ Relative Xpath
Street Number or House Number
★ Index based Xpath
★ Finding using other attributes
★ Partial Matching
Let’s go advanced..
Complex Selectors
★ Partial Matching
Description CSS Xpath
Starting with ^= starts-with()
Ending with $= ends-with()
Contains *= contains()
Few more, Complex Selectors
★ Elements based on relationships
Xpath : ancestor, descendent, preceding, following
CSS: :first-child, :last-child, :nth-child(n)
★ Based on UI state
CSS: enabled, disabled, checked, :not()
Cheat Sheet
Handy Reference for CSS/Xpath
Approach Description/HTML CSS Xpath
Finding by ID <input id='user'> input#user //input[@id='user']
Finding by Class <input class='user'> input.user //input[@class='user']
Any attribute <input name='text'> input[name='text'] //input[@name='text']
Direct Child <ul> has several <li> ul > li //ul/li
Any Child/Grandchild <ul> has several <li> ul li //ul//li
nth-child 4th <li> from <ul> ul li:nth-of-type(4) //ul/li[4]
Direct Parent <ul> is parent of <li class='active'> li.active:parent //li[@class='active']/..
Next Sibling 2nd <li> tag from several <li> tags li.active + li //li[@class='active']/../li[2]
By Text Link with Sign In text a:contains('Sign In') //a[contains(text(), 'Sign In')]
Best Practices from
Experience
Make scripts more robust...
★ Avoid fragile selectors like ones having numbers or text that
appears to be variable
★ Don’t rely on a hierarchy of elements above 3-4 levels
★ Avoid using more than 2 attributes for a composite selector
★ Ensure the selectors in all browsers using the console
★ Store Element locators outside your classes … Excel/XML/Text
anywhere but not in your code.
★ At times, you may avoid GUI automation too !!!
Happy to answer any questions/queries
related to Automation testing …..
Slides will be available on -
http://drvaya.wordpress.com/

More Related Content

Viewers also liked

Trabalho De Ingles
Trabalho De InglesTrabalho De Ingles
Trabalho De Inglesguesta66cf0
 
Object Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non StaticObject Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non StaticAbdul Rahman Sherzad
 
Lecture 2 introduction to Software Engineering 1
Lecture 2   introduction to Software Engineering 1Lecture 2   introduction to Software Engineering 1
Lecture 2 introduction to Software Engineering 1IIUI
 
Software Engineering 2 lecture slide
Software Engineering 2 lecture slideSoftware Engineering 2 lecture slide
Software Engineering 2 lecture slideAdil Mehmoood
 
Object Oriented Concept
Object Oriented ConceptObject Oriented Concept
Object Oriented ConceptD Nayanathara
 
1-Introduction to Software Engineering (Object Oriented Software Engineering ...
1-Introduction to Software Engineering (Object Oriented Software Engineering ...1-Introduction to Software Engineering (Object Oriented Software Engineering ...
1-Introduction to Software Engineering (Object Oriented Software Engineering ...Hafiz Ammar Siddiqui
 
Object Modelling in Software Engineering
Object Modelling in Software EngineeringObject Modelling in Software Engineering
Object Modelling in Software Engineeringguest7fe55d5e
 
Object Oriented Concept
Object Oriented ConceptObject Oriented Concept
Object Oriented Conceptsmj
 
Software Engineering unit 2
Software Engineering unit 2Software Engineering unit 2
Software Engineering unit 2Abhimanyu Mishra
 
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsMaryo Manjaruni
 
Exploring BigData with Google BigQuery
Exploring BigData with Google BigQueryExploring BigData with Google BigQuery
Exploring BigData with Google BigQueryDharmesh Vaya
 
Object Oriented Software Engineering
Object Oriented Software EngineeringObject Oriented Software Engineering
Object Oriented Software EngineeringAli Haider
 
Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12koolkampus
 
Lecture 2 Software Engineering and Design Object Oriented Programming, Design...
Lecture 2 Software Engineering and Design Object Oriented Programming, Design...Lecture 2 Software Engineering and Design Object Oriented Programming, Design...
Lecture 2 Software Engineering and Design Object Oriented Programming, Design...op205
 
Object identification and its management
Object identification and its managementObject identification and its management
Object identification and its managementVinay Kumar Pulabaigari
 
Object oriented software engineering concepts
Object oriented software engineering conceptsObject oriented software engineering concepts
Object oriented software engineering conceptsKomal Singh
 

Viewers also liked (17)

Trabalho De Ingles
Trabalho De InglesTrabalho De Ingles
Trabalho De Ingles
 
Object Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non StaticObject Oriented Concept Static vs. Non Static
Object Oriented Concept Static vs. Non Static
 
Lecture 2 introduction to Software Engineering 1
Lecture 2   introduction to Software Engineering 1Lecture 2   introduction to Software Engineering 1
Lecture 2 introduction to Software Engineering 1
 
Software Engineering 2 lecture slide
Software Engineering 2 lecture slideSoftware Engineering 2 lecture slide
Software Engineering 2 lecture slide
 
Object Oriented Concept
Object Oriented ConceptObject Oriented Concept
Object Oriented Concept
 
1-Introduction to Software Engineering (Object Oriented Software Engineering ...
1-Introduction to Software Engineering (Object Oriented Software Engineering ...1-Introduction to Software Engineering (Object Oriented Software Engineering ...
1-Introduction to Software Engineering (Object Oriented Software Engineering ...
 
Object Modelling in Software Engineering
Object Modelling in Software EngineeringObject Modelling in Software Engineering
Object Modelling in Software Engineering
 
Object Oriented Concept
Object Oriented ConceptObject Oriented Concept
Object Oriented Concept
 
Software Engineering unit 2
Software Engineering unit 2Software Engineering unit 2
Software Engineering unit 2
 
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented concepts
 
Exploring BigData with Google BigQuery
Exploring BigData with Google BigQueryExploring BigData with Google BigQuery
Exploring BigData with Google BigQuery
 
Object Oriented Software Engineering
Object Oriented Software EngineeringObject Oriented Software Engineering
Object Oriented Software Engineering
 
Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12
 
Lecture 2 Software Engineering and Design Object Oriented Programming, Design...
Lecture 2 Software Engineering and Design Object Oriented Programming, Design...Lecture 2 Software Engineering and Design Object Oriented Programming, Design...
Lecture 2 Software Engineering and Design Object Oriented Programming, Design...
 
Object identification and its management
Object identification and its managementObject identification and its management
Object identification and its management
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Object oriented software engineering concepts
Object oriented software engineering conceptsObject oriented software engineering concepts
Object oriented software engineering concepts
 

Similar to Hands-on Guide to Object Identification

New Features of Chropath for XPath and CSS Selectors | Edureka
New Features of Chropath for XPath and CSS Selectors | EdurekaNew Features of Chropath for XPath and CSS Selectors | Edureka
New Features of Chropath for XPath and CSS Selectors | EdurekaEdureka!
 
Introduction to html & css
Introduction to html & cssIntroduction to html & css
Introduction to html & csssesharao puvvada
 
Cartegraph Live HTML, CSS, JavaScript and jQuery Training
Cartegraph Live HTML, CSS, JavaScript and jQuery TrainingCartegraph Live HTML, CSS, JavaScript and jQuery Training
Cartegraph Live HTML, CSS, JavaScript and jQuery TrainingShane Church
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS MethodologyZohar Arad
 
Railsbridge javascript
Railsbridge   javascriptRailsbridge   javascript
Railsbridge javascriptp4geoff
 
J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012ghnash
 
Understanding CSS Selectors in Selenium.pdf
Understanding CSS Selectors in Selenium.pdfUnderstanding CSS Selectors in Selenium.pdf
Understanding CSS Selectors in Selenium.pdfpCloudy
 
Chrome DevTools Introduction 2020 Web Developers Guide
Chrome DevTools Introduction 2020 Web Developers GuideChrome DevTools Introduction 2020 Web Developers Guide
Chrome DevTools Introduction 2020 Web Developers GuideLaurence Svekis ✔
 
Extreme CSS Techniques - MadWorld Europe 2018, Scott DeLoach, ClickStart
Extreme CSS Techniques - MadWorld Europe 2018, Scott DeLoach, ClickStartExtreme CSS Techniques - MadWorld Europe 2018, Scott DeLoach, ClickStart
Extreme CSS Techniques - MadWorld Europe 2018, Scott DeLoach, ClickStartScott DeLoach
 
Doing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon LondonDoing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon LondonGábor Hojtsy
 
FFW Gabrovo PMG - jQuery
FFW Gabrovo PMG - jQueryFFW Gabrovo PMG - jQuery
FFW Gabrovo PMG - jQueryToni Kolev
 
Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6Marakana Inc.
 
2010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-62010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-6Marakana Inc.
 
PhDigital Bootcamp: Web Development Concepts
PhDigital Bootcamp: Web Development ConceptsPhDigital Bootcamp: Web Development Concepts
PhDigital Bootcamp: Web Development ConceptsCindy Royal
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsMark Rackley
 
Core Web Standards and Competencies - WritersUA East 2015, Scott DeLoach, Cli...
Core Web Standards and Competencies - WritersUA East 2015, Scott DeLoach, Cli...Core Web Standards and Competencies - WritersUA East 2015, Scott DeLoach, Cli...
Core Web Standards and Competencies - WritersUA East 2015, Scott DeLoach, Cli...Scott DeLoach
 

Similar to Hands-on Guide to Object Identification (20)

New Features of Chropath for XPath and CSS Selectors | Edureka
New Features of Chropath for XPath and CSS Selectors | EdurekaNew Features of Chropath for XPath and CSS Selectors | Edureka
New Features of Chropath for XPath and CSS Selectors | Edureka
 
Introduction to html & css
Introduction to html & cssIntroduction to html & css
Introduction to html & css
 
css v1 guru
css v1 gurucss v1 guru
css v1 guru
 
CSS Selectors
CSS SelectorsCSS Selectors
CSS Selectors
 
Cartegraph Live HTML, CSS, JavaScript and jQuery Training
Cartegraph Live HTML, CSS, JavaScript and jQuery TrainingCartegraph Live HTML, CSS, JavaScript and jQuery Training
Cartegraph Live HTML, CSS, JavaScript and jQuery Training
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
 
Railsbridge javascript
Railsbridge   javascriptRailsbridge   javascript
Railsbridge javascript
 
J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012
 
Understanding CSS Selectors in Selenium.pdf
Understanding CSS Selectors in Selenium.pdfUnderstanding CSS Selectors in Selenium.pdf
Understanding CSS Selectors in Selenium.pdf
 
Chrome DevTools Introduction 2020 Web Developers Guide
Chrome DevTools Introduction 2020 Web Developers GuideChrome DevTools Introduction 2020 Web Developers Guide
Chrome DevTools Introduction 2020 Web Developers Guide
 
Less css
Less cssLess css
Less css
 
Extreme CSS Techniques - MadWorld Europe 2018, Scott DeLoach, ClickStart
Extreme CSS Techniques - MadWorld Europe 2018, Scott DeLoach, ClickStartExtreme CSS Techniques - MadWorld Europe 2018, Scott DeLoach, ClickStart
Extreme CSS Techniques - MadWorld Europe 2018, Scott DeLoach, ClickStart
 
Doing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon LondonDoing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon London
 
FFW Gabrovo PMG - jQuery
FFW Gabrovo PMG - jQueryFFW Gabrovo PMG - jQuery
FFW Gabrovo PMG - jQuery
 
Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6
 
2010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-62010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-6
 
PhDigital Bootcamp: Web Development Concepts
PhDigital Bootcamp: Web Development ConceptsPhDigital Bootcamp: Web Development Concepts
PhDigital Bootcamp: Web Development Concepts
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentials
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
Core Web Standards and Competencies - WritersUA East 2015, Scott DeLoach, Cli...
Core Web Standards and Competencies - WritersUA East 2015, Scott DeLoach, Cli...Core Web Standards and Competencies - WritersUA East 2015, Scott DeLoach, Cli...
Core Web Standards and Competencies - WritersUA East 2015, Scott DeLoach, Cli...
 

Recently uploaded

Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptrcbcrtm
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 

Recently uploaded (20)

Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 

Hands-on Guide to Object Identification

  • 1. Hands-on guide to Object Identification Speaker : Dharmesh Vaya Presented On : 24.06.2016 Twitter : @DRVaya Web : http://drvaya.wordpress.com/
  • 2. Test Automation Consultant with 10+ yrs experience Expertise with designing/development of Selenium based Automation frameworks (as well as other tools) Speaker at various forums - Google DevFests, Selenium Conference Trainer/Mentor - to different MNCs/Startups. Dharmesh Vaya a.k.a. Dharam
  • 3. Agenda ★ Basics of Object Identification ★ What are CSS Selectors/Locator’s ? ★ What are Xpath Locators ? ★ Let’s go advanced … ★ Cheat Sheet ★ Best Practices from experience
  • 5. Approach ... ★ More than locators you need to understand the underlying Web development techniques. ★ Carefully understand the page source and identify the libraries used. This will help in building robust scripts. ★ Using Firebug/Developer tools. ★ Test your element even before you do it with Selenium. (Developer toolbars are meant for that). ★ Ultimately, Locators come first, Logic is secondary and will be built upon the locators.
  • 7. CSS Selectors... ★ Absolute Selectors World -> Continent -> Country -> State -> City -> Street ★ Relative Selectors Street Number or House Number ★ Class or ID based Selectors ★ Finding using other attributes ★ Partial Matching
  • 9. Xpath Locators... ★ Absolute Xpath World -> Continent -> Country -> State -> City -> Street ★ Relative Xpath Street Number or House Number ★ Index based Xpath ★ Finding using other attributes ★ Partial Matching
  • 11. Complex Selectors ★ Partial Matching Description CSS Xpath Starting with ^= starts-with() Ending with $= ends-with() Contains *= contains()
  • 12. Few more, Complex Selectors ★ Elements based on relationships Xpath : ancestor, descendent, preceding, following CSS: :first-child, :last-child, :nth-child(n) ★ Based on UI state CSS: enabled, disabled, checked, :not()
  • 14. Handy Reference for CSS/Xpath Approach Description/HTML CSS Xpath Finding by ID <input id='user'> input#user //input[@id='user'] Finding by Class <input class='user'> input.user //input[@class='user'] Any attribute <input name='text'> input[name='text'] //input[@name='text'] Direct Child <ul> has several <li> ul > li //ul/li Any Child/Grandchild <ul> has several <li> ul li //ul//li nth-child 4th <li> from <ul> ul li:nth-of-type(4) //ul/li[4] Direct Parent <ul> is parent of <li class='active'> li.active:parent //li[@class='active']/.. Next Sibling 2nd <li> tag from several <li> tags li.active + li //li[@class='active']/../li[2] By Text Link with Sign In text a:contains('Sign In') //a[contains(text(), 'Sign In')]
  • 16. Make scripts more robust... ★ Avoid fragile selectors like ones having numbers or text that appears to be variable ★ Don’t rely on a hierarchy of elements above 3-4 levels ★ Avoid using more than 2 attributes for a composite selector ★ Ensure the selectors in all browsers using the console ★ Store Element locators outside your classes … Excel/XML/Text anywhere but not in your code. ★ At times, you may avoid GUI automation too !!!
  • 17. Happy to answer any questions/queries related to Automation testing ….. Slides will be available on - http://drvaya.wordpress.com/