SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

UFT Automation Framework Introduction
UFT Automation Framework IntroductionUFT Automation Framework Introduction
UFT Automation Framework Introduction
Himal Bandara
 

Tendances (20)

Automation Testing with KATALON Cucumber BDD
Automation Testing with KATALON Cucumber BDDAutomation Testing with KATALON Cucumber BDD
Automation Testing with KATALON Cucumber BDD
 
Katalon Studio Presentation.pptx
Katalon Studio Presentation.pptxKatalon Studio Presentation.pptx
Katalon Studio Presentation.pptx
 
Execute Automation Testing in 3 Steps
Execute Automation Testing in 3 StepsExecute Automation Testing in 3 Steps
Execute Automation Testing in 3 Steps
 
Automation With A Tool Demo
Automation With A Tool DemoAutomation With A Tool Demo
Automation With A Tool Demo
 
Selenium
SeleniumSelenium
Selenium
 
How to select the right automated testing tool
How to select the right automated testing toolHow to select the right automated testing tool
How to select the right automated testing tool
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Patterns of a “good” test automation framework
Patterns of a “good” test automation frameworkPatterns of a “good” test automation framework
Patterns of a “good” test automation framework
 
Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
 
Locators in selenium - BNT 09
Locators in selenium - BNT 09Locators in selenium - BNT 09
Locators in selenium - BNT 09
 
Software Testing Tutorial For Beginners | Manual & Automation Testing | Selen...
Software Testing Tutorial For Beginners | Manual & Automation Testing | Selen...Software Testing Tutorial For Beginners | Manual & Automation Testing | Selen...
Software Testing Tutorial For Beginners | Manual & Automation Testing | Selen...
 
Test automation
Test automationTest automation
Test automation
 
Setting up Page Object Model in Automation Framework
Setting up Page Object Model in Automation FrameworkSetting up Page Object Model in Automation Framework
Setting up Page Object Model in Automation Framework
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD
 
API Testing With Katalon Studio
API Testing With Katalon StudioAPI Testing With Katalon Studio
API Testing With Katalon Studio
 
Test automation framework
Test automation frameworkTest automation framework
Test automation framework
 
Selenium
SeleniumSelenium
Selenium
 
UFT Automation Framework Introduction
UFT Automation Framework IntroductionUFT Automation Framework Introduction
UFT Automation Framework Introduction
 
Software Testing - Part 1 (Techniques, Types, Levels, Methods, STLC, Bug Life...
Software Testing - Part 1 (Techniques, Types, Levels, Methods, STLC, Bug Life...Software Testing - Part 1 (Techniques, Types, Levels, Methods, STLC, Bug Life...
Software Testing - Part 1 (Techniques, Types, Levels, Methods, STLC, Bug Life...
 
Test Automation Framework Design | www.idexcel.com
Test Automation Framework Design | www.idexcel.comTest Automation Framework Design | www.idexcel.com
Test Automation Framework Design | www.idexcel.com
 

Similaire à Locator strategy for web elements | Katalon Studio

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
Marakana Inc.
 

Similaire à Locator strategy for web elements | Katalon Studio (20)

EVOLVE'13 | Enhance | Effective SEO | Paul Legan
EVOLVE'13 | Enhance | Effective SEO | Paul LeganEVOLVE'13 | Enhance | Effective SEO | Paul Legan
EVOLVE'13 | Enhance | Effective SEO | Paul Legan
 
Search engine optimization (seo) courses in chandigarh
Search engine optimization (seo) courses in chandigarhSearch engine optimization (seo) courses in chandigarh
Search engine optimization (seo) courses in chandigarh
 
Search Engine Optimization courses in ghaziabad, Search engine Optimization t...
Search Engine Optimization courses in ghaziabad, Search engine Optimization t...Search Engine Optimization courses in ghaziabad, Search engine Optimization t...
Search Engine Optimization courses in ghaziabad, Search engine Optimization t...
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
 
Search engine optimization ,seo in vashali,seo training in Mohan nagar,seo in...
Search engine optimization ,seo in vashali,seo training in Mohan nagar,seo in...Search engine optimization ,seo in vashali,seo training in Mohan nagar,seo in...
Search engine optimization ,seo in vashali,seo training in Mohan nagar,seo in...
 
Search engine optimization,Best SEO institute in Ghaziabad,SEO Courses in Gha...
Search engine optimization,Best SEO institute in Ghaziabad,SEO Courses in Gha...Search engine optimization,Best SEO institute in Ghaziabad,SEO Courses in Gha...
Search engine optimization,Best SEO institute in Ghaziabad,SEO Courses in Gha...
 
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
 
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
 
The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015
 
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePointSPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
 
Apex & jQuery Mobile
Apex & jQuery MobileApex & jQuery Mobile
Apex & jQuery Mobile
 
SPTechCon DevDays - SharePoint & jQuery
SPTechCon DevDays - SharePoint & jQuerySPTechCon DevDays - SharePoint & jQuery
SPTechCon DevDays - SharePoint & jQuery
 
Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap
 
SEF2013 - A jQuery Primer for SharePoint
SEF2013 - A jQuery Primer for SharePointSEF2013 - A jQuery Primer for SharePoint
SEF2013 - A jQuery Primer for SharePoint
 
Seo
SeoSeo
Seo
 
JQuery
JQueryJQuery
JQuery
 
JQuery
JQueryJQuery
JQuery
 
Search Engine Optimization (SEO)
Search Engine Optimization (SEO)Search Engine Optimization (SEO)
Search Engine Optimization (SEO)
 
A Deep Dive Into SEO Tactics For Modern Javascript Frameworks
A Deep Dive Into SEO Tactics For Modern Javascript FrameworksA Deep Dive Into SEO Tactics For Modern Javascript Frameworks
A Deep Dive Into SEO Tactics For Modern Javascript Frameworks
 
Html5
Html5Html5
Html5
 

Dernier

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Dernier (20)

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 

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’]]