SlideShare a Scribd company logo
1 of 43
Download to read offline
PATTERNS OF A “GOOD”
TEST AUTOMATION
FRAMEWORK, LOCATORS
& DATA!
Anand Bagmar
Test Practice Lead
@BagmarAnand
about.me/anand.bagmar
ABOUT ME
Test Automation
Principle
Code Quality
What is a
Design Pattern?
Have you heard-of or
used any
Patterns for Test
Automation?
COMMON PATTERNS USED IN TEST AUTOMATION
¨ Page-Object
¨ Business Layer
¨ Singleton
¨ Composition
¨ Factory
¨ Builder
Test Automation
Framework Patterns
Case Study
Code sample - #1
Page-Object Pattern
PAGE OBJECT PATTERN
Model pages
in code
Simulates user actions
One place change
Reduces code duplication
Snippets
of page
AUTOMATION FRAMEWORK WITH PAGE OBJECTS
Code sample - #2
As the framework
evolves ….
AUTOMATION FRAMEWORK WITH PAGE OBJECTS
Code sample - #3
LIMITATIONS OF PAGE-OBJECT PATTERN
¨ Test intent gets polluted
¨ Duplication of Test intent & implementation
¨ Intent becomes Imperative
¨ Maintenance challenges
¨ Scaling challenges
Business-Layer
Page-Object Pattern
BUSINESS-LAYER PAGE-OBJECT PATTERN
Code sample - #4
ADVANTAGES OF
BUSINESS-LAYER PAGE-OBJECT PATTERN
¨ Validate what is important - Business requirements
¨ Test Pyramid remains sane
¨ Abstraction layers allow separation-of-concerns
¨ Changes are isolated
¨ Maintenance & Scaling becomes ‘easier’
Test Data Patterns
Why do we need to
think differently
about Test Data?
CRITERIA FOR TEST DATA
¨ Data is complex
¨ Needs to mimic “real” data
¨ Needs to be unique
¨ Data can be nested
¨ Though specified as static, may need to be Dynamic
¨ Data can be shared and reused
DIFFERENT WAYS TO SPECIFY TEST DATA
¨ In Test implementation
¨ In Test specification / intent
¨ In code … separate data structures / classes / etc.
¨ External files
TEST DATA SPECIFICATION EXAMPLES
¨ Excel
¨ CSV
¨ Property
¨ XML
¨ YAML
¨ Database
¨ Json
Code sample - #5
CRITERIA FOR SELECTION
¨ Easy to specify
¨ Easy to read and consume (by test framework)
¨ Ability to override specified data, easily
¨ Usable
TIPS FOR IMPLEMENTATION
¨ Consistent way to specify test data
¨ Read the data – as Business Entities
¨ Override as appropriate
¨ Create DSL to give meaning to data
¨ Use in test implementation
¨ Implement Test Data Entity Utilities – Build, Equals, Copy,
Find, etc.
Locators’ Patterns
DIFFERENT WAYS TO SPECIFY ELEMENT LOCATORS
¨ In Page-Objects
¨ In separate files, per Page-Object
¨ In external files / locator files
Advantages of
using Patterns for
Test Automation
ADVANTAGES OF PATTERNS
¨ Well known, well understood
¨ Tried & tested solutions for common problems
¨ Reduces complexity
¨ Language neutral
¨ Aid in communication
ADVANTAGES OF PATTERNS IN TEST AUTOMATION
Saves time & effort
(eventually)
Single ownership
Test Automation Code is of Production Quality!
Single point of change
Easy to –
- Implement
- Maintain
- Debug
- Scale
WHICH IS THE “BEST” PATTERN TO USE ?
It DEPENDS!
on the
Context!
REFERENCES
Page Objects – Google
https://code.google.com/p/selenium/wiki/PageObjects
Page Objects – Martin Fowler
http://martinfowler.com/bliki/PageObject.html
Perils of Page-Object Pattern – Anand Bagmar
http://essenceoftesting.blogspot.in/2014/09/perils-of-page-object-pattern.html
Test Design Consideration
http://docs.seleniumhq.org/docs/06_test_design_considerations.jsp
abagmar@gmail.com
Anand.Bagmar@thoughtworks.com
@BagmarAnand
about.me/anand.bagmar
THANK YOU

More Related Content

What's hot

What's hot (20)

Client-Side Performance Testing
Client-Side Performance TestingClient-Side Performance Testing
Client-Side Performance Testing
 
Say NO To (More) Selenium Tests
Say NO To (More) Selenium TestsSay NO To (More) Selenium Tests
Say NO To (More) Selenium Tests
 
Enabling CD in Enterprises with Testing
Enabling CD in Enterprises with TestingEnabling CD in Enterprises with Testing
Enabling CD in Enterprises with Testing
 
Automating Web Analytics
Automating Web AnalyticsAutomating Web Analytics
Automating Web Analytics
 
Role of Automation in Testing
Role of Automation in TestingRole of Automation in Testing
Role of Automation in Testing
 
Eradicate Flaky Tests - AppiumConf 2021
Eradicate Flaky Tests - AppiumConf 2021Eradicate Flaky Tests - AppiumConf 2021
Eradicate Flaky Tests - AppiumConf 2021
 
What is Agile Testing? How does Automation help?
What is Agile Testing? How does Automation help?What is Agile Testing? How does Automation help?
What is Agile Testing? How does Automation help?
 
An easy way to automate complex UI
An easy way to automate complex UIAn easy way to automate complex UI
An easy way to automate complex UI
 
Selenium Deep Dive
Selenium Deep DiveSelenium Deep Dive
Selenium Deep Dive
 
Brace yourself from automation death trap
Brace yourself from automation death trapBrace yourself from automation death trap
Brace yourself from automation death trap
 
The What, Why and How of Analytics Testing
The What, Why and How of Analytics TestingThe What, Why and How of Analytics Testing
The What, Why and How of Analytics Testing
 
Grading the Quality of Selenium Tests
Grading the Quality of Selenium TestsGrading the Quality of Selenium Tests
Grading the Quality of Selenium Tests
 
Software Test Patterns: Successes and Challenges
Software Test Patterns: Successes and ChallengesSoftware Test Patterns: Successes and Challenges
Software Test Patterns: Successes and Challenges
 
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object Pattern
 
Measuring Coverage From E2E Tests
Measuring Coverage From E2E TestsMeasuring Coverage From E2E Tests
Measuring Coverage From E2E Tests
 
Visual Validation - The Missing Tip of the Automation Pyramid
Visual Validation - The Missing Tip of the Automation PyramidVisual Validation - The Missing Tip of the Automation Pyramid
Visual Validation - The Missing Tip of the Automation Pyramid
 
Build the "right" regression suite using Behavior Driven Testing (BDT)
Build the "right" regression suite using Behavior Driven Testing (BDT)Build the "right" regression suite using Behavior Driven Testing (BDT)
Build the "right" regression suite using Behavior Driven Testing (BDT)
 
Design patterns in test automation
Design patterns in test automationDesign patterns in test automation
Design patterns in test automation
 
Agile Testing Dilemmas
Agile Testing DilemmasAgile Testing Dilemmas
Agile Testing Dilemmas
 
Increase automation to rest
Increase automation to restIncrease automation to rest
Increase automation to rest
 

Similar to Patterns in Test Automation

Selenium-online-training
Selenium-online-trainingSelenium-online-training
Selenium-online-training
Raghav Arora
 
Using Compass to Diagnose Performance Problems in Your Cluster
Using Compass to Diagnose Performance Problems in Your ClusterUsing Compass to Diagnose Performance Problems in Your Cluster
Using Compass to Diagnose Performance Problems in Your Cluster
MongoDB
 
Using Compass to Diagnose Performance Problems
Using Compass to Diagnose Performance Problems Using Compass to Diagnose Performance Problems
Using Compass to Diagnose Performance Problems
MongoDB
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
Adam Birr
 
Software Testing: Application And Script Independent Automation Framework: Th...
Software Testing: Application And Script Independent Automation Framework: Th...Software Testing: Application And Script Independent Automation Framework: Th...
Software Testing: Application And Script Independent Automation Framework: Th...
guest0efb5e
 
Integration Testing in Enterprises using TaaS
Integration Testing in Enterprises using TaaSIntegration Testing in Enterprises using TaaS
Integration Testing in Enterprises using TaaS
Anand Bagmar
 

Similar to Patterns in Test Automation (20)

Patterns of Test Automation
Patterns of Test AutomationPatterns of Test Automation
Patterns of Test Automation
 
Unit testing
Unit testingUnit testing
Unit testing
 
Selenium-online-training
Selenium-online-trainingSelenium-online-training
Selenium-online-training
 
2010-07-19_rails_tdd_week1
2010-07-19_rails_tdd_week12010-07-19_rails_tdd_week1
2010-07-19_rails_tdd_week1
 
Using Compass to Diagnose Performance Problems in Your Cluster
Using Compass to Diagnose Performance Problems in Your ClusterUsing Compass to Diagnose Performance Problems in Your Cluster
Using Compass to Diagnose Performance Problems in Your Cluster
 
Using Compass to Diagnose Performance Problems
Using Compass to Diagnose Performance Problems Using Compass to Diagnose Performance Problems
Using Compass to Diagnose Performance Problems
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Create an architecture for web test automation
Create an architecture for web test automationCreate an architecture for web test automation
Create an architecture for web test automation
 
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестамDSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
 
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxDSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
 
Migration strategies 4
Migration strategies 4Migration strategies 4
Migration strategies 4
 
Approaching ATDD/BDD
Approaching ATDD/BDDApproaching ATDD/BDD
Approaching ATDD/BDD
 
Frequently Bought Together Recommendations Based on Embeddings
Frequently Bought Together Recommendations Based on EmbeddingsFrequently Bought Together Recommendations Based on Embeddings
Frequently Bought Together Recommendations Based on Embeddings
 
Software Testing: Application And Script Independent Automation Framework: Th...
Software Testing: Application And Script Independent Automation Framework: Th...Software Testing: Application And Script Independent Automation Framework: Th...
Software Testing: Application And Script Independent Automation Framework: Th...
 
Testing the Untestable
Testing the UntestableTesting the Untestable
Testing the Untestable
 
Automate across Platform, OS, Technologies with TaaS
Automate across Platform, OS, Technologies with TaaSAutomate across Platform, OS, Technologies with TaaS
Automate across Platform, OS, Technologies with TaaS
 
Ken Brooks: How Publishers Start with XML--The View From the Front Lines
Ken Brooks: How Publishers Start with XML--The View From the Front LinesKen Brooks: How Publishers Start with XML--The View From the Front Lines
Ken Brooks: How Publishers Start with XML--The View From the Front Lines
 
Pa Project And Best Practice 2
Pa Project And Best Practice 2Pa Project And Best Practice 2
Pa Project And Best Practice 2
 
Integration Testing in Enterprises using TaaS
Integration Testing in Enterprises using TaaSIntegration Testing in Enterprises using TaaS
Integration Testing in Enterprises using TaaS
 
Using Page Objects
Using Page ObjectsUsing Page Objects
Using Page Objects
 

More from Anand Bagmar

More from Anand Bagmar (17)

Eradicate Flaky Tests
Eradicate Flaky TestsEradicate Flaky Tests
Eradicate Flaky Tests
 
Automating the real-user scenarios across multi-apps, and multi-devices
Automating the real-user scenarios across multi-apps, and multi-devicesAutomating the real-user scenarios across multi-apps, and multi-devices
Automating the real-user scenarios across multi-apps, and multi-devices
 
Visual Validation - The missing tip of the automation pyramid @GoT2022
Visual Validation - The missing tip of the automation pyramid @GoT2022Visual Validation - The missing tip of the automation pyramid @GoT2022
Visual Validation - The missing tip of the automation pyramid @GoT2022
 
Design Patterns in Automation
Design Patterns in AutomationDesign Patterns in Automation
Design Patterns in Automation
 
Change Tyres In A Moving Car - Make Functional Test Automation Effective Keynote
Change Tyres In A Moving Car - Make Functional Test Automation Effective KeynoteChange Tyres In A Moving Car - Make Functional Test Automation Effective Keynote
Change Tyres In A Moving Car - Make Functional Test Automation Effective Keynote
 
Rewrite vs Refactor (AgileIndia 2021)
Rewrite vs Refactor (AgileIndia 2021)Rewrite vs Refactor (AgileIndia 2021)
Rewrite vs Refactor (AgileIndia 2021)
 
Next Generation Functional & Visual Testing powered by AI
Next Generation Functional & Visual Testing powered by AINext Generation Functional & Visual Testing powered by AI
Next Generation Functional & Visual Testing powered by AI
 
The Best Test Automation Framework is...
The Best Test Automation Framework is...The Best Test Automation Framework is...
The Best Test Automation Framework is...
 
Getting started with Appium 2.0
Getting started with Appium 2.0Getting started with Appium 2.0
Getting started with Appium 2.0
 
Visual Validation - The missing tip of the automation pyramid @AgileIndia2020
Visual Validation - The missing tip of the automation pyramid @AgileIndia2020Visual Validation - The missing tip of the automation pyramid @AgileIndia2020
Visual Validation - The missing tip of the automation pyramid @AgileIndia2020
 
Does your functional automation really add value?
Does your functional automation really add value?Does your functional automation really add value?
Does your functional automation really add value?
 
Getting started with Visual Testing using Applitools - @TPC, Feb2020
Getting started with Visual Testing using Applitools - @TPC, Feb2020Getting started with Visual Testing using Applitools - @TPC, Feb2020
Getting started with Visual Testing using Applitools - @TPC, Feb2020
 
Visual validation - The missing tip of the automation pyramid @ QA Symposium
Visual validation - The missing tip of the automation pyramid @ QA SymposiumVisual validation - The missing tip of the automation pyramid @ QA Symposium
Visual validation - The missing tip of the automation pyramid @ QA Symposium
 
Collaboration - A Taboo!
Collaboration - A Taboo!Collaboration - A Taboo!
Collaboration - A Taboo!
 
Measuring Consumer Quality - The Missing Feedback Loop
Measuring Consumer Quality - The Missing Feedback LoopMeasuring Consumer Quality - The Missing Feedback Loop
Measuring Consumer Quality - The Missing Feedback Loop
 
Sharing the pain using Protractor
Sharing the pain using ProtractorSharing the pain using Protractor
Sharing the pain using Protractor
 
Test Automation - Principles and Practices
Test Automation - Principles and PracticesTest Automation - Principles and Practices
Test Automation - Principles and Practices
 

Recently uploaded

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
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
 

Recently uploaded (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
 
%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
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%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
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
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
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
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 🔝✔️✔️
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 

Patterns in Test Automation