際際滷

際際滷Share a Scribd company logo
LOCATOR
STRATEGIES FOR
WEB ELEMENTS
WEB UI AUTOMATED TESTS
By Trong Bui - QA Architect at KMS Technology
LOCATOR STRATEGIES FOR WEB ELEMENTS
LOCATOR
 A way to find a Web element by Selenium
 Locator strategies: ID, Name, Link, DOM, XPath, etc.
 Challenges
 Unable to find elements
 Multiple elements matched
 Hard to maintain scripts
 Vulnerable to changes in the implementation of the AUT
LOCATOR STRATEGIES FOR WEB ELEMENTS
LOCATOR STRATEGIES
 This chart provides several useful locator strategies in
addition to the common ones, including
 Using Visual Text
 Detecting Component
LOCATOR STRATEGIES FOR WEB ELEMENTS
USING VISUAL TEXT
An element is located using its visual text such as title, label and caption instead of its
properties invisible by end users such as ID and index.
Pros
 Focusing on What users see
 Tests are more readable
 Visual texts are often specified in the requirements
 Avoiding unexpected changes in the back-end implementation
 Supporting localization
Cons
 Problems with localization
 Problems in dealing with Web Element relationships
LOCATOR STRATEGIES FOR WEB ELEMENTS
USING VISUAL TEXT
 Visual text appearing as
 Value
 Text
 Placeholder
 Bound label
LOCATOR STRATEGIES FOR WEB ELEMENTS
VALUE
<input accesskey="s" class="aui-button" id="login-form-submit" name="login"
title="Press Alt+s to submit this form" type="submit" value="Log In">
locator: //input[@value = Log In]
locator: //<tag>[@value = <present text>]
LOCATOR STRATEGIES FOR WEB ELEMENTS
TEXT
<button class="btn Searchbox__searchButton Searchbox__searchButton--active" data-sel
<span class="Searchbox__searchButton__text">Search</span>
</button>
locator: //span[(text() = 'Search' or . = 'Search')]
locator: //button[.=Search]
locator: //<tag>[.=<present text>]
LOCATOR STRATEGIES FOR WEB ELEMENTS
PLACE HOLDER
<input type="email" autocomplete="username"
class="_43sdyhr" id="email-signup-email" name="user[email]"
placeholder="Email address" value="">
locator: //input[@placeholder=Email address]
locator: //<tag>[@placeholder=<present text>]
LOCATOR STRATEGIES FOR WEB ELEMENTS
PLACE HOLDER<input type="text" class="_1lhx92j" aria-label="Check in"
id="checkin" name="checkin" value=2018-05-15"
placeholder="Check in" autocomplete="off" aria-
describedby="DateInput__screen-reader-message-checkin">
locator: //input[@placeholder=Check in]
locator: //<tag>[@placeholder=<present text>]
LOCATOR STRATEGIES FOR WEB ELEMENTS
BOUND LABEL
<div class="field-group">
<label accesskey="u" for="login-form-username"><u>U</u>sername</label>
<input class="text medium-field" id="login-form-username" name="os_username" type="tex
</div>
locator: .//input[@id=//label[.=Username]/@for]
locator: .//<tag>[@id=//label[.=<present text>]/@for]
LOCATOR STRATEGIES FOR WEB ELEMENTS
BOUND LABEL
<div class="_9hxttoo">
<label class="_1m8bb6v" for="GeocompleteController-via-SearchBarV2-SearchBarV2">Where</label>
<div dir="ltr">
<div class="_v0d63vq"><div class="_ncmdki"><div class="_bp0th8"><div class="_1miobth"><svg viewBox="0
0 24 24" role="presentation" aria-hidden="true" focusable="false" style="" fill-
rule="evenodd"></path></svg></div></div></div><div class="_178faes">
<input type="text" autocomplete="off" class="_k3jto05" id="GeocompleteController-via-SearchBarV2-
SearchBarV2" name="query" placeholder="Try Costa Blanca" value=""></div>
</div>
</div></div>
locator: //input[@id=//label[.=Where]/@for]
LOCATOR STRATEGIES FOR WEB ELEMENTS
DETECTING COMPONENT
 A component consists of related Web elements. Users view
a component as a whole instead of individual elements
 Examples are search result blocks, carousels
 A component is located as a whole instead of its individual
elements
LOCATOR STRATEGIES FOR WEB ELEMENTS
COMPONENT
<div class="_16nvkt52"><div class="_qgh1p4">
<button type="button" class="_6m75u2" aria-busy="false" data-veloute="explore-nav-card:/homes">
<div><div class="_112c092"><div class="_1thk0tsb"><div class="_e296pg" style="width: 96px; height:
72px;"><div class="_6ikqekk" style=""></div></div></div><div class="_ni9axhe"><div
class="_13lgpze"><div class="_1ho874em">
<span class="_1t073h8">Homes</span>
</div></div></div></div></div>
</button>
</div></div>
Locator: .//button[.//span[.=Homes]]
LOCATOR STRATEGIES FOR WEB ELEMENTS
COMPONENT
LOCATOR STRATEGIES FOR WEB ELEMENTS
COMPONENT
Locator: .//div[@itemprop=itemListElement][.//div[.=Penthouse Room Close
to Big Ben]]
Thank you
Ad

Recommended

PDF
Katalon Studio - Best automation solution for software testing team
Katalon Studio
PPTX
Automation Testing of Shadow DOM Elements with Katalon Studio
Katalon Studio
ODP
Why Katalon Studio?
Knoldus Inc.
DOCX
Katalon studio vs selenium comparision
Prabhusundar6
PPTX
Katalon Studio - GUI Overview
Katalon Studio
PDF
Katalon: Mobile and Browser-Based Automation | Quality Jam 2018
Katalon Studio
PDF
Test Case Creation in Katalon Studio
RapidValue
PDF
Selenium IDE LOCATORS
Mindfire Solutions
PPTX
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Pankaj Dubey
PDF
Automation Testing with KATALON Cucumber BDD
RapidValue
PDF
Tricentis Tosca - Email Notification of Execution Reports
Bilal Ahmed
PPTX
Selenium ppt
Aneesh Rangarajan
PDF
Katalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio
PPTX
Execute Automation Testing in 3 Steps
ExecuteAutomation
PDF
Page Object Model and Implementation in Selenium
Zoe Gilbert
PPT
Selenium Primer
gueste1e4db
PDF
Introduzione ad angular 7/8
Valerio Radice
PPTX
Maven
Emprovise
PPTX
Introduction to Maven
Mindfire Solutions
PDF
SonarQube
Gnanaseelan Jeb
PPTX
Data driven testing
ng Minh
PPTX
Unit testing
際際滷share
PPTX
Selenium WebDriver training
Vijay Krishnan Ramaswamy
PDF
Testing Angular
Lilia Sfaxi
PDF
Test Automation Frameworks Using Selenium | Edureka
Edureka!
PPTX
Hybrid automation framework
doai tran
PPTX
Terraform
Adam Vincze
PPTX
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
PPTX
From Code to Commerce, a Backend Java Developer's Galactic Journey into Ecomm...
Jamie Coleman

More Related Content

What's hot (20)

PPTX
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Pankaj Dubey
PDF
Automation Testing with KATALON Cucumber BDD
RapidValue
PDF
Tricentis Tosca - Email Notification of Execution Reports
Bilal Ahmed
PPTX
Selenium ppt
Aneesh Rangarajan
PDF
Katalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio
PPTX
Execute Automation Testing in 3 Steps
ExecuteAutomation
PDF
Page Object Model and Implementation in Selenium
Zoe Gilbert
PPT
Selenium Primer
gueste1e4db
PDF
Introduzione ad angular 7/8
Valerio Radice
PPTX
Maven
Emprovise
PPTX
Introduction to Maven
Mindfire Solutions
PDF
SonarQube
Gnanaseelan Jeb
PPTX
Data driven testing
ng Minh
PPTX
Unit testing
際際滷share
PPTX
Selenium WebDriver training
Vijay Krishnan Ramaswamy
PDF
Testing Angular
Lilia Sfaxi
PDF
Test Automation Frameworks Using Selenium | Edureka
Edureka!
PPTX
Hybrid automation framework
doai tran
PPTX
Terraform
Adam Vincze
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Pankaj Dubey
Automation Testing with KATALON Cucumber BDD
RapidValue
Tricentis Tosca - Email Notification of Execution Reports
Bilal Ahmed
Selenium ppt
Aneesh Rangarajan
Katalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio
Execute Automation Testing in 3 Steps
ExecuteAutomation
Page Object Model and Implementation in Selenium
Zoe Gilbert
Selenium Primer
gueste1e4db
Introduzione ad angular 7/8
Valerio Radice
Maven
Emprovise
Introduction to Maven
Mindfire Solutions
SonarQube
Gnanaseelan Jeb
Data driven testing
ng Minh
Unit testing
際際滷share
Selenium WebDriver training
Vijay Krishnan Ramaswamy
Testing Angular
Lilia Sfaxi
Test Automation Frameworks Using Selenium | Edureka
Edureka!
Hybrid automation framework
doai tran
Terraform
Adam Vincze

Recently uploaded (20)

PPTX
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
PPTX
From Code to Commerce, a Backend Java Developer's Galactic Journey into Ecomm...
Jamie Coleman
PDF
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
PDF
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
PDF
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
PPTX
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
PDF
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
WSO2
PPTX
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
PDF
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
PPTX
arctitecture application system design os dsa
za241967
PPTX
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
DOCX
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
PPTX
Simplify Insurance Regulations with Compliance Management Software
Insurance Tech Services
PDF
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
PDF
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
PPTX
Sap basis role in public cloud in s/4hana.pptx
htmlprogrammer987
PDF
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
PDF
Automated Testing and Safety Analysis of Deep Neural Networks
Lionel Briand
PPTX
Key Challenges in Troubleshooting Customer On-Premise Applications
Tier1 app
PDF
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
From Code to Commerce, a Backend Java Developer's Galactic Journey into Ecomm...
Jamie Coleman
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
WSO2
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
arctitecture application system design os dsa
za241967
Advance Doctor Appointment Booking App With Online Payment
AxisTechnolabs
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
Simplify Insurance Regulations with Compliance Management Software
Insurance Tech Services
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
Sap basis role in public cloud in s/4hana.pptx
htmlprogrammer987
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
Automated Testing and Safety Analysis of Deep Neural Networks
Lionel Briand
Key Challenges in Troubleshooting Customer On-Premise Applications
Tier1 app
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
Ad

Locator strategy for web elements | Katalon Studio

  • 1. LOCATOR STRATEGIES FOR WEB ELEMENTS WEB UI AUTOMATED TESTS By Trong Bui - QA Architect at KMS Technology
  • 2. LOCATOR STRATEGIES FOR WEB ELEMENTS LOCATOR A way to find a Web element by Selenium Locator strategies: ID, Name, Link, DOM, XPath, etc. Challenges Unable to find elements Multiple elements matched Hard to maintain scripts Vulnerable to changes in the implementation of the AUT
  • 3. LOCATOR STRATEGIES FOR WEB ELEMENTS LOCATOR STRATEGIES This chart provides several useful locator strategies in addition to the common ones, including Using Visual Text Detecting Component
  • 4. LOCATOR STRATEGIES FOR WEB ELEMENTS USING VISUAL TEXT An element is located using its visual text such as title, label and caption instead of its properties invisible by end users such as ID and index. Pros Focusing on What users see Tests are more readable Visual texts are often specified in the requirements Avoiding unexpected changes in the back-end implementation Supporting localization Cons Problems with localization Problems in dealing with Web Element relationships
  • 5. LOCATOR STRATEGIES FOR WEB ELEMENTS USING VISUAL TEXT Visual text appearing as Value Text Placeholder Bound label
  • 6. LOCATOR STRATEGIES FOR WEB ELEMENTS VALUE <input accesskey="s" class="aui-button" id="login-form-submit" name="login" title="Press Alt+s to submit this form" type="submit" value="Log In"> locator: //input[@value = Log In] locator: //<tag>[@value = <present text>]
  • 7. LOCATOR STRATEGIES FOR WEB ELEMENTS TEXT <button class="btn Searchbox__searchButton Searchbox__searchButton--active" data-sel <span class="Searchbox__searchButton__text">Search</span> </button> locator: //span[(text() = 'Search' or . = 'Search')] locator: //button[.=Search] locator: //<tag>[.=<present text>]
  • 8. LOCATOR STRATEGIES FOR WEB ELEMENTS PLACE HOLDER <input type="email" autocomplete="username" class="_43sdyhr" id="email-signup-email" name="user[email]" placeholder="Email address" value=""> locator: //input[@placeholder=Email address] locator: //<tag>[@placeholder=<present text>]
  • 9. LOCATOR STRATEGIES FOR WEB ELEMENTS PLACE HOLDER<input type="text" class="_1lhx92j" aria-label="Check in" id="checkin" name="checkin" value=2018-05-15" placeholder="Check in" autocomplete="off" aria- describedby="DateInput__screen-reader-message-checkin"> locator: //input[@placeholder=Check in] locator: //<tag>[@placeholder=<present text>]
  • 10. LOCATOR STRATEGIES FOR WEB ELEMENTS BOUND LABEL <div class="field-group"> <label accesskey="u" for="login-form-username"><u>U</u>sername</label> <input class="text medium-field" id="login-form-username" name="os_username" type="tex </div> locator: .//input[@id=//label[.=Username]/@for] locator: .//<tag>[@id=//label[.=<present text>]/@for]
  • 11. LOCATOR STRATEGIES FOR WEB ELEMENTS BOUND LABEL <div class="_9hxttoo"> <label class="_1m8bb6v" for="GeocompleteController-via-SearchBarV2-SearchBarV2">Where</label> <div dir="ltr"> <div class="_v0d63vq"><div class="_ncmdki"><div class="_bp0th8"><div class="_1miobth"><svg viewBox="0 0 24 24" role="presentation" aria-hidden="true" focusable="false" style="" fill- rule="evenodd"></path></svg></div></div></div><div class="_178faes"> <input type="text" autocomplete="off" class="_k3jto05" id="GeocompleteController-via-SearchBarV2- SearchBarV2" name="query" placeholder="Try Costa Blanca" value=""></div> </div> </div></div> locator: //input[@id=//label[.=Where]/@for]
  • 12. LOCATOR STRATEGIES FOR WEB ELEMENTS DETECTING COMPONENT A component consists of related Web elements. Users view a component as a whole instead of individual elements Examples are search result blocks, carousels A component is located as a whole instead of its individual elements
  • 13. LOCATOR STRATEGIES FOR WEB ELEMENTS COMPONENT <div class="_16nvkt52"><div class="_qgh1p4"> <button type="button" class="_6m75u2" aria-busy="false" data-veloute="explore-nav-card:/homes"> <div><div class="_112c092"><div class="_1thk0tsb"><div class="_e296pg" style="width: 96px; height: 72px;"><div class="_6ikqekk" style=""></div></div></div><div class="_ni9axhe"><div class="_13lgpze"><div class="_1ho874em"> <span class="_1t073h8">Homes</span> </div></div></div></div></div> </button> </div></div> Locator: .//button[.//span[.=Homes]]
  • 14. LOCATOR STRATEGIES FOR WEB ELEMENTS COMPONENT
  • 15. LOCATOR STRATEGIES FOR WEB ELEMENTS COMPONENT Locator: .//div[@itemprop=itemListElement][.//div[.=Penthouse Room Close to Big Ben]]