Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
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 beco...
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 remai...
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 s...
DIFFERENT WAYS TO SPECIFY TEST DATA
¨ In Test implementation
¨ In Test specification / intent
¨ In code … separate data str...
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 dat...
TIPS FOR IMPLEMENTATION
¨ Consistent way to specify test data
¨ Read the data – as Business Entities
¨ Override as appropr...
Locators’ Patterns
DIFFERENT WAYS TO SPECIFY ELEMENT LOCATORS
¨ In Page-Objects
¨ In separate files, per Page-Object
¨ In external files / loca...
Advantages of
using Patterns for
Test Automation
ADVANTAGES OF PATTERNS
¨ Well known, well understood
¨ Tried & tested solutions for common problems
¨ Reduces complexity
¨...
ADVANTAGES OF PATTERNS IN TEST AUTOMATION
Saves time & effort
(eventually)
Single ownership
Test Automation Code is of Prod...
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://m...
abagmar@gmail.com
Anand.Bagmar@thoughtworks.com
@BagmarAnand
about.me/anand.bagmar
THANK YOU
Patterns in Test Automation
Patterns in Test Automation
Patterns in Test Automation
Patterns in Test Automation
Upcoming SlideShare
Loading in …5
×

Patterns in Test Automation

23,862 views

Published on

Building a Test Automation Framework is easy - there are so many resources / guides / blogs / etc. available to help you get started and help solve the issues you get along the journey.

However, building a "good" Test Automation Framework is not very easy. There are a lot of principles and practices you need to use, in the right context, with a good set of skills required to make the Test Automation Framework maintainable, scalable and reusable.

Design Patterns play a big role in helping achieve this goal of building a good and robust framework.

In this talk, we will talk about, and see examples of various types of patterns you can use for:

Build your Test Automation Framework
Test Data Management
Locators / IDs (for finding / interacting with elements in the browser / app)
Using these patterns you will be able to build a good framework, that will help keep your tests running fast, and reliably in your CI / CD setup!

Published in: Software
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Patterns in Test Automation

  1. 1. PATTERNS OF A “GOOD” TEST AUTOMATION FRAMEWORK, LOCATORS & DATA! Anand Bagmar Test Practice Lead
  2. 2. @BagmarAnand about.me/anand.bagmar ABOUT ME
  3. 3. Test Automation Principle
  4. 4. Code Quality
  5. 5. What is a Design Pattern?
  6. 6. Have you heard-of or used any Patterns for Test Automation?
  7. 7. COMMON PATTERNS USED IN TEST AUTOMATION ¨ Page-Object ¨ Business Layer ¨ Singleton ¨ Composition ¨ Factory ¨ Builder
  8. 8. Test Automation Framework Patterns
  9. 9. Case Study
  10. 10. Code sample - #1
  11. 11. Page-Object Pattern
  12. 12. PAGE OBJECT PATTERN Model pages in code Simulates user actions One place change Reduces code duplication Snippets of page
  13. 13. AUTOMATION FRAMEWORK WITH PAGE OBJECTS
  14. 14. Code sample - #2
  15. 15. As the framework evolves ….
  16. 16. AUTOMATION FRAMEWORK WITH PAGE OBJECTS
  17. 17. Code sample - #3
  18. 18. LIMITATIONS OF PAGE-OBJECT PATTERN ¨ Test intent gets polluted ¨ Duplication of Test intent & implementation ¨ Intent becomes Imperative ¨ Maintenance challenges ¨ Scaling challenges
  19. 19. Business-Layer Page-Object Pattern
  20. 20. BUSINESS-LAYER PAGE-OBJECT PATTERN
  21. 21. Code sample - #4
  22. 22. 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’
  23. 23. Test Data Patterns
  24. 24. Why do we need to think differently about Test Data?
  25. 25. 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
  26. 26. DIFFERENT WAYS TO SPECIFY TEST DATA ¨ In Test implementation ¨ In Test specification / intent ¨ In code … separate data structures / classes / etc. ¨ External files
  27. 27. TEST DATA SPECIFICATION EXAMPLES ¨ Excel ¨ CSV ¨ Property ¨ XML ¨ YAML ¨ Database ¨ Json
  28. 28. Code sample - #5
  29. 29. CRITERIA FOR SELECTION ¨ Easy to specify ¨ Easy to read and consume (by test framework) ¨ Ability to override specified data, easily ¨ Usable
  30. 30. 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.
  31. 31. Locators’ Patterns
  32. 32. DIFFERENT WAYS TO SPECIFY ELEMENT LOCATORS ¨ In Page-Objects ¨ In separate files, per Page-Object ¨ In external files / locator files
  33. 33. Advantages of using Patterns for Test Automation
  34. 34. ADVANTAGES OF PATTERNS ¨ Well known, well understood ¨ Tried & tested solutions for common problems ¨ Reduces complexity ¨ Language neutral ¨ Aid in communication
  35. 35. 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
  36. 36. WHICH IS THE “BEST” PATTERN TO USE ?
  37. 37. It DEPENDS! on the Context!
  38. 38. 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
  39. 39. abagmar@gmail.com Anand.Bagmar@thoughtworks.com @BagmarAnand about.me/anand.bagmar THANK YOU

×