SlideShare a Scribd company logo
Object identification &
its management in
Selenium WebDriver
-VINAY KUMAR P
Object Identification
 For testing different applications i.e. Application Under Test (AUT), we need to
identify the object it is made of. It is consisting of different objects like below:
 Button
 Text Box
 Link
 Drop Down
 Radio Button
 List Box
 Slider
 Object identification is very important part of automation activity. So the
automation people should be able to identify the objects for automation purpose.
 For identifying these objects Selenium uses a concept of ‘Locators’. These locators
are used to identify the objects which are mostly used while automating the test
cases using Selenium.
 Locators: There are number of locators present. These are among them.
 ID
 Name
 XPath
 CSS
 Class
 tagName
 Link Text
 Filters
 Finding an element and confirming the expected result requires locators.
The 'By' class is used in WebDriver to locate the elements. These are as below:
Locator : ID
Syntax :-
By.id(id);
Locator : Name
Syntax :-
By.name(name);
Locator : Class
Syntax :-
By.class(class);
Locator : tagName
Syntax :-
By.tagName(name);
Locator : Link Text
Syntax :-
By.linkText(linkText);
Locator : CSS
Syntax :-
By.cssSelector(selector);
Locator : XPath
Syntax :-
By.xpath(xpath);
Locator : Filters
Syntax :-
By.partialLinkText(partialLinkTe
xt);
Different ways of writing the XPaths
 The following are different ways of writing the XPaths:-
 Based upon location: A node element can be identified based upon its Absolute or Relative
path.
 Absolute path :- it starts from the root element of the html code.
 //html/body/div[@id="WebPartWPQ2"]/div[1]/div[2]/div[1]/div[1]/div[5]
 Relative path :- it starts from a preceding string of the html code.
 //*[@id="lst-ib"]
 Based upon attributes
 Single
 //button[@id='gbqfba']
 Multiple
 //button[@id='gbqfba'] [@name=‘xyz]
 Based upon relative
 //div[@id='gbqfbwa']/button“
 Based upon position
 //div[2]/button
XPath Axes
Ancestor
To find nearest ancestor/
parent element that contains
an element that has an
attribute with a certain value
Syntax:-
//*[ancestor::foo[bar[@attr="v
al"]]]
Descendants
To find nearest Descendants/
child element that contains an
element that has an attribute
with a certain value
Syntax:-
//id('books')/descendant::td[@cl
ass='title']
following-sibling
To find all following sibling
element
Syntax:-
//ul/li[following-
sibling::li='roger']
Parent
Each element and attribute
has one parent
Syntax:-
//*[@class='bodywrapper']/pa
rent::*
Child
Child returns all the children in
the current node.
Syntax:-
//*[@class='sphinxsidebarwra
pper']/child::*
preceding-sibling
To find preceding sibling
element
Syntax:-
//ul/li[preceding-
sibling::li='bob' ]
XPath Axes
Self
To returns the current node.
Syntax:-
//*[@class='footer']/self::div
Attribute
It returns all the attributes in
the current node
Syntax:-
//*[@class='sphinxsidebarwra
pper']/attribute::*
following
Following returns all in the
document after the closing
tag of the current node.
Syntax:-
//*[@class='clearer']/following
::*
preceding
Preceding is a reverse of
Following; Preceding returns
all in the document before the
current node
Syntax:-
//*[@class='bodywrapper']/pr
eceding::*
Contains()
Contains() is a method used in XPath
expression. It is used when the value of
any attribute changes dynamically
The contain feature has an ability to find
the element with partial text
Syntax:-
//*[contains(@type,'sub')]
//*[contains(@name,'btn')]
//*[contains(text(),'here')]
//*[contains(@href,'guru99.com')]
Object Management
Object management
 Test automation predominantly revolves around GUI, objects i.e. various UI controls.
Ability of an automation tool to deal with objects is certainly important when selecting
an automation tool for your Application-Under-Test (AUT). At the same time, how you
look at using it for Object Management is just as important.
 Object Management is not mere object identification, but a lot more than that. The
following list will throw some light on what I mean:
 Object Identification – Tool algorithm used to identify objects – Name, ID, Link, XPath, etc. that
will work across browsers. Do I need technical skills to identify objects?
 Object Repository – Let me know when objects are added by other users to avoid relearning
and improve reusability
 Object Maintenance - Let me know when objects are added or removed within AUT for me
understand the impact of object change
Object identification
 Object identification, to be more precise, objects being identified
accurately demands certain steps to be followed and is certainly not a
straight forward experience in Selenium WebDriver.
 SELENIUM -WEBDRIVER offers a range of locators to point to a specific object
in AUT. To name a few – ID, Name, XPath, CSS, etc.
 There are tools such as Firebug that can provide a much deeper
understanding of the objects. The drawback here is that it demands
understanding of HTML DOM to help you decide how to deal with objects
to derive the best object identification locator.
Object repository
 Object repository is a collection of object and properties with which
automation tool will be able to recognize the objects and act on it.
 Having a centralized Object Repository is an absolute necessity for any test
automation initiative to be sustainable.
 In a multi-user environment, Object Repository reduces duplication of effort
involved in learning objects if another user has already defined those objects.
Only new or changed objects need to be dealt with. Most automation tools
would provide for some form of Object Repository.
 Selenium WebDriver offers no object repository implementation by default.
 Page object model help us to overcome the drawback of Selenium
WebDriver.
Object Maintenance
 A change in application can be introduction of new UI or change in existing UI. In
either of the case one must know which objects are already present in the
repository and which objects in AUT have undergone a change and require
update in Object Repository.
 Many are lost in this phase, ending up with relearning the objects / making
changes to object without knowing the impacted test cases. As a result you have
to maintain duplicate objects or you get unnecessary failures during execution.
 An automation tool that can help you understand the impact of any object
change would go a long way in addressing the headaches associated with Object
Management. For e.g.:
 Functionality that provides you a list of test cases that will be impacted by an object
change instantly will help faster decision-making and changes.
 Ability to update an object once and all test cases using that object are automatically
updated
 Most currently available tools provide this information post an execution failure –
basically.
Impact of Object Management on Automation ROI
 Object management that looks beyond the basics of object identification will
have a much larger impact on ROI from a test automation exercise.
Incomplete and under-utilized Object Management will have adverse
consequences such as:
 Productivity slows down
 Maintenance efforts increase
 Overall cost is increased as against anticipated savings
 Above all, readiness of automation suite is not guaranteed when required
 Suffice to say that Object Management needs a deeper thought and hence, it
is fair to conclude that Object Management mechanism cannot be taken
lightly when using Selenium WebDriver as your automation technology.
Thank you…

More Related Content

PPTX
Easy mock
DOCX
ObjectCreatorUserGuide
ODP
(An Extended) Beginners Guide to Object Orientation in PHP
PPTX
Advance java session 11
PPTX
Easy ORMness with Objectify-Appengine
PPTX
MVC and Entity Framework
PPT
Entity Persistence with JPA
ODP
JPA Best Practices
Easy mock
ObjectCreatorUserGuide
(An Extended) Beginners Guide to Object Orientation in PHP
Advance java session 11
Easy ORMness with Objectify-Appengine
MVC and Entity Framework
Entity Persistence with JPA
JPA Best Practices

What's hot (19)

PDF
Hibernate An Introduction
PPTX
Introduction to JPA (JPA version 2.0)
PPTX
MVC and Entity Framework 4
PDF
PPTX
Introduction to jQuery
PPTX
JQUERY TUTORIALS
PPT
Hibernate Tutorial
PPTX
Real World MVC
PPTX
Introduction to Hibernate Framework
PPTX
07.3. Android Alert message, List, Dropdown, and Auto Complete
PPTX
Introduction to JPA Framework
PPTX
Easy mockppt
ODP
Hibernate complete Training
PDF
Vaadin JPAContainer
PDF
Java persistence api 2.1
PPT
Introduction to hibernate
PPTX
Back-2-Basics: .NET Coding Standards For The Real World
PPTX
JPA For Beginner's
PPTX
jQuery basics for Beginners
Hibernate An Introduction
Introduction to JPA (JPA version 2.0)
MVC and Entity Framework 4
Introduction to jQuery
JQUERY TUTORIALS
Hibernate Tutorial
Real World MVC
Introduction to Hibernate Framework
07.3. Android Alert message, List, Dropdown, and Auto Complete
Introduction to JPA Framework
Easy mockppt
Hibernate complete Training
Vaadin JPAContainer
Java persistence api 2.1
Introduction to hibernate
Back-2-Basics: .NET Coding Standards For The Real World
JPA For Beginner's
jQuery basics for Beginners
Ad

Viewers also liked (20)

PPT
Qtp Object Identification
DOCX
Trabalho De Ingles
PDF
Hands-on Guide to Object Identification
PDF
Object Oriented Concept Static vs. Non Static
PPT
Lecture 2 introduction to Software Engineering 1
PPT
Software Engineering 2 lecture slide
PPTX
Object Oriented Concept
PDF
1-Introduction to Software Engineering (Object Oriented Software Engineering ...
PPTX
Object Modelling in Software Engineering
PPT
Object Oriented Concept
 
PPTX
Software Engineering unit 2
PPT
Jedi slides 2.1 object-oriented concepts
PPTX
Object Oriented Software Engineering
PPT
Object Oriented Design in Software Engineering SE12
DOCX
Pramod Kumar Behera
PDF
Winwin love prezentace
DOCX
Mani Resume
PPTX
Javascript Exploitation
PPTX
Gamify Your Fundraiser
PDF
45b8e1ce2
Qtp Object Identification
Trabalho De Ingles
Hands-on Guide to Object Identification
Object Oriented Concept Static vs. Non Static
Lecture 2 introduction to Software Engineering 1
Software Engineering 2 lecture slide
Object Oriented Concept
1-Introduction to Software Engineering (Object Oriented Software Engineering ...
Object Modelling in Software Engineering
Object Oriented Concept
 
Software Engineering unit 2
Jedi slides 2.1 object-oriented concepts
Object Oriented Software Engineering
Object Oriented Design in Software Engineering SE12
Pramod Kumar Behera
Winwin love prezentace
Mani Resume
Javascript Exploitation
Gamify Your Fundraiser
45b8e1ce2
Ad

Similar to Object identification and its management (20)

PPTX
Automatedtestingwithselenium shubham jain
PPTX
Locators and webdriver commands Selenium Session2.pptx
PPTX
xpaths.pptx
PPTX
Automated_Testing_Selenium
PPTX
Automation Testing by Selenium Web Driver
PDF
Selenium Overview
PDF
Selenium with testng and eclipse ide
PPTX
Agile_unit_2_newdddcdcdscdssvvdvdsvdsv.pptx
PPTX
Agile_unit_2_newdddcdcdscdssvvdvdsvdsv.pptx
PDF
Intelligent Testing Tool: Selenium Web Driver
PDF
Efficient Rails Test-Driven Development - Week 6
PDF
2010 07-18.wa.rails tdd-6
PDF
Selenium Introduction by Sandeep Sharda
PPTX
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
PPT
Test Automation Framework Development Introduction
PDF
Using XPath in Selenium - All you need to know.pdf
DOCX
Selenium notes
PPT
Dynamic Content in QTP
PPTX
Selenium training
PPTX
Automation Testing
Automatedtestingwithselenium shubham jain
Locators and webdriver commands Selenium Session2.pptx
xpaths.pptx
Automated_Testing_Selenium
Automation Testing by Selenium Web Driver
Selenium Overview
Selenium with testng and eclipse ide
Agile_unit_2_newdddcdcdscdssvvdvdsvdsv.pptx
Agile_unit_2_newdddcdcdscdssvvdvdsvdsv.pptx
Intelligent Testing Tool: Selenium Web Driver
Efficient Rails Test-Driven Development - Week 6
2010 07-18.wa.rails tdd-6
Selenium Introduction by Sandeep Sharda
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Test Automation Framework Development Introduction
Using XPath in Selenium - All you need to know.pdf
Selenium notes
Dynamic Content in QTP
Selenium training
Automation Testing

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Big Data Technologies - Introduction.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Cloud computing and distributed systems.
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
KodekX | Application Modernization Development
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Chapter 3 Spatial Domain Image Processing.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Reach Out and Touch Someone: Haptics and Empathic Computing
Mobile App Security Testing_ A Comprehensive Guide.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Big Data Technologies - Introduction.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
Machine learning based COVID-19 study performance prediction
NewMind AI Weekly Chronicles - August'25 Week I
Dropbox Q2 2025 Financial Results & Investor Presentation
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Review of recent advances in non-invasive hemoglobin estimation
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Cloud computing and distributed systems.
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KodekX | Application Modernization Development
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf

Object identification and its management

  • 1. Object identification & its management in Selenium WebDriver -VINAY KUMAR P
  • 3.  For testing different applications i.e. Application Under Test (AUT), we need to identify the object it is made of. It is consisting of different objects like below:  Button  Text Box  Link  Drop Down  Radio Button  List Box  Slider  Object identification is very important part of automation activity. So the automation people should be able to identify the objects for automation purpose.
  • 4.  For identifying these objects Selenium uses a concept of ‘Locators’. These locators are used to identify the objects which are mostly used while automating the test cases using Selenium.  Locators: There are number of locators present. These are among them.  ID  Name  XPath  CSS  Class  tagName  Link Text  Filters  Finding an element and confirming the expected result requires locators.
  • 5. The 'By' class is used in WebDriver to locate the elements. These are as below: Locator : ID Syntax :- By.id(id); Locator : Name Syntax :- By.name(name); Locator : Class Syntax :- By.class(class); Locator : tagName Syntax :- By.tagName(name); Locator : Link Text Syntax :- By.linkText(linkText); Locator : CSS Syntax :- By.cssSelector(selector); Locator : XPath Syntax :- By.xpath(xpath); Locator : Filters Syntax :- By.partialLinkText(partialLinkTe xt);
  • 6. Different ways of writing the XPaths  The following are different ways of writing the XPaths:-  Based upon location: A node element can be identified based upon its Absolute or Relative path.  Absolute path :- it starts from the root element of the html code.  //html/body/div[@id="WebPartWPQ2"]/div[1]/div[2]/div[1]/div[1]/div[5]  Relative path :- it starts from a preceding string of the html code.  //*[@id="lst-ib"]  Based upon attributes  Single  //button[@id='gbqfba']  Multiple  //button[@id='gbqfba'] [@name=‘xyz]  Based upon relative  //div[@id='gbqfbwa']/button“  Based upon position  //div[2]/button
  • 7. XPath Axes Ancestor To find nearest ancestor/ parent element that contains an element that has an attribute with a certain value Syntax:- //*[ancestor::foo[bar[@attr="v al"]]] Descendants To find nearest Descendants/ child element that contains an element that has an attribute with a certain value Syntax:- //id('books')/descendant::td[@cl ass='title'] following-sibling To find all following sibling element Syntax:- //ul/li[following- sibling::li='roger'] Parent Each element and attribute has one parent Syntax:- //*[@class='bodywrapper']/pa rent::* Child Child returns all the children in the current node. Syntax:- //*[@class='sphinxsidebarwra pper']/child::* preceding-sibling To find preceding sibling element Syntax:- //ul/li[preceding- sibling::li='bob' ]
  • 8. XPath Axes Self To returns the current node. Syntax:- //*[@class='footer']/self::div Attribute It returns all the attributes in the current node Syntax:- //*[@class='sphinxsidebarwra pper']/attribute::* following Following returns all in the document after the closing tag of the current node. Syntax:- //*[@class='clearer']/following ::* preceding Preceding is a reverse of Following; Preceding returns all in the document before the current node Syntax:- //*[@class='bodywrapper']/pr eceding::* Contains() Contains() is a method used in XPath expression. It is used when the value of any attribute changes dynamically The contain feature has an ability to find the element with partial text Syntax:- //*[contains(@type,'sub')] //*[contains(@name,'btn')] //*[contains(text(),'here')] //*[contains(@href,'guru99.com')]
  • 10. Object management  Test automation predominantly revolves around GUI, objects i.e. various UI controls. Ability of an automation tool to deal with objects is certainly important when selecting an automation tool for your Application-Under-Test (AUT). At the same time, how you look at using it for Object Management is just as important.  Object Management is not mere object identification, but a lot more than that. The following list will throw some light on what I mean:  Object Identification – Tool algorithm used to identify objects – Name, ID, Link, XPath, etc. that will work across browsers. Do I need technical skills to identify objects?  Object Repository – Let me know when objects are added by other users to avoid relearning and improve reusability  Object Maintenance - Let me know when objects are added or removed within AUT for me understand the impact of object change
  • 11. Object identification  Object identification, to be more precise, objects being identified accurately demands certain steps to be followed and is certainly not a straight forward experience in Selenium WebDriver.  SELENIUM -WEBDRIVER offers a range of locators to point to a specific object in AUT. To name a few – ID, Name, XPath, CSS, etc.  There are tools such as Firebug that can provide a much deeper understanding of the objects. The drawback here is that it demands understanding of HTML DOM to help you decide how to deal with objects to derive the best object identification locator.
  • 12. Object repository  Object repository is a collection of object and properties with which automation tool will be able to recognize the objects and act on it.  Having a centralized Object Repository is an absolute necessity for any test automation initiative to be sustainable.  In a multi-user environment, Object Repository reduces duplication of effort involved in learning objects if another user has already defined those objects. Only new or changed objects need to be dealt with. Most automation tools would provide for some form of Object Repository.  Selenium WebDriver offers no object repository implementation by default.  Page object model help us to overcome the drawback of Selenium WebDriver.
  • 13. Object Maintenance  A change in application can be introduction of new UI or change in existing UI. In either of the case one must know which objects are already present in the repository and which objects in AUT have undergone a change and require update in Object Repository.  Many are lost in this phase, ending up with relearning the objects / making changes to object without knowing the impacted test cases. As a result you have to maintain duplicate objects or you get unnecessary failures during execution.  An automation tool that can help you understand the impact of any object change would go a long way in addressing the headaches associated with Object Management. For e.g.:  Functionality that provides you a list of test cases that will be impacted by an object change instantly will help faster decision-making and changes.  Ability to update an object once and all test cases using that object are automatically updated  Most currently available tools provide this information post an execution failure – basically.
  • 14. Impact of Object Management on Automation ROI  Object management that looks beyond the basics of object identification will have a much larger impact on ROI from a test automation exercise. Incomplete and under-utilized Object Management will have adverse consequences such as:  Productivity slows down  Maintenance efforts increase  Overall cost is increased as against anticipated savings  Above all, readiness of automation suite is not guaranteed when required  Suffice to say that Object Management needs a deeper thought and hence, it is fair to conclude that Object Management mechanism cannot be taken lightly when using Selenium WebDriver as your automation technology.