SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Downloaden Sie, um offline zu lesen
Page Objects:
You’re Doing It Wrong
#badpageobject
Titus Fortner
Sr Solution Architect at Sauce Labs
@titusfortner
2
• @titusfortner
• Former SDET
• Open Source
• Senior Solution Architect
at Sauce Labs!
© Sauce Labs, Inc.
Titus Fortner
Ground Rules
1. “My Opinions Are Correct”
2. I have too many a lot of Opinions
3. Make Informed Decisions
Law of the Instrument
● You Can Make Anything “Work”
○ How long for a new employee to understand?
○ How long for your replacement to understand?
○ Have you considered alternatives?
My Priors
● End to End DOM to Database
● Scalable Test Automation Requires Tests be
○ Atomic, Autonomous, and Short
● Optimize Maintainability not “Correctness”
● Prefer Simple/Clear to Easy/Fast
A Page Object is…
an object oriented class that stores information about the services provided
by a specific view in an application’s User Interface.
● Browser vs Mobile App
● Desktop Browser vs Mobile Browser
● Page / Modal / Section
● Action Methods & Element Definitions
What Problems Do Page Objects Solve?
● Maintenance, Maintenance, Maintenance
● Separation of Concerns
● DRY
A place for everything and everything in its place
-Benjamin Franklin
Conventions for Maintainability
● Consistency
● Principle of Least Surprise
Page Object Critiques
● Abstract LESS!
○ YAGNI
○ Keep code base smaller by not over-abstracting
● Abstract MOAR!
○ Single Responsibility Principle
○ Keep classes smaller with more of them
Page Object Principles
● Avoid Imperative
● Avoid Nondeterministic
● Avoid Complicated Constructors
● Avoid Coupling
● Avoid Assertions
● Avoid Ambivalence
be
Declarative
not
Imperative
1
• How
• Implementation Logic
• Specific Details
• All Data
Declarative Imperative
• What
• Business Logic
• Big Picture
• Contextual Data
Imperative Example
Declarative Example
Things That Encourage Imperative
● “Keyword Driven” Testing
○ Robot Framework
● “Data Driven” Testing (BDD?)
● Test Libraries with special matchers
○ Nightwatch.js
○ Site Prism gem
○ Selenide jar
● Property Files
be
Deterministic
not
Nondeterministic
2
Checking State for Flow Control
• Synchronization Issues
• Your Test “Already Knows”
• What driver are you using?
• What Config determined the driver?
Subclass / Factory / Interface
use
Simple Constructors
not
Magic Constructors
3
Validating State in Constructor
● Good Idea – User shouldn’t care how state is set to arrive on the page
What Your Users Will Do…
● Relying on “Magic” things in Insufficient Places is Less Clear
Page Object Should Know Where it Lives
● Implement a visit method to be explicit
• Re-use instead of Re-implementing
• Be Direct!
be
De-Coupled
not
Coupled
4
Coupled Objects
Fluent Pattern
● Errors are not captured at compile time
● Debuggers / Stack Trace inaccuracies
● Weird Names to make fun sentences in your code
● Subclasses must explicitly define all return values from the fluent
interface
PO Pattern Specific Objections
● Code repeatability: Options for re-using a LogIn Modal from Cart & Home Page?
○ Different Classes? Methods?
○ Intermittently skip returning instance values
● Your Deterministic test “Already Knows” what it is doing;
○ Don’t store the same information in multiple places
● Is the Return Value Obvious?
● “Visit” method provide state
● Atomic test theoretically only needs one Page Object
De-Coupled
do
Raise Exceptions
do not
Make Assertions
5
Intention
I Have Evaluated the “Functionality I Care About” and Have
Determined that it: is / is not
Working as Intended
Vs
I am unable to evaluate whether the “Functionality I Care
About” is working as intended
Better Information
do
Consider Method Intent
do not
Use Ambivalent Methods
6
Common Test Pattern
Unhelpful Information
Not finding an element isn’t the real problem
Some previous step unsuccessful
Intentional Method
Anti-Patterns that didn’t make the cut
● Don’t rely on standard Error Messages
● Use Additional Classes to avoid overloading the Base Page
● Avoid too many levels of subclass
● Allow a Page Object to define ”success” as an implementation detail
● Avoid Multiple Inheritance
● Avoid Soft Assertions
● Don’t Define Methods & Elements that you don’t already have a test for
● Do not look for the absence of an element
● All Reusability needs to exist in Page Object not in Steps / Test Code
How About You?
Tweet at me
@titusfortner
Your Bad Page Object Experiences
#badpageobject
Thank you.

Weitere ähnliche Inhalte

Was ist angesagt?

Игорь Бондаренко (Neklo) - Организация процесса разработки модулей для Magento
Игорь Бондаренко (Neklo) - Организация процесса разработки модулей для MagentoИгорь Бондаренко (Neklo) - Организация процесса разработки модулей для Magento
Игорь Бондаренко (Neklo) - Организация процесса разработки модулей для Magento
meet_magento
 
Максим Климишин "Що такого особливого у пропозиції вартості шаблону Micro Fro...
Максим Климишин "Що такого особливого у пропозиції вартості шаблону Micro Fro...Максим Климишин "Що такого особливого у пропозиції вартості шаблону Micro Fro...
Максим Климишин "Що такого особливого у пропозиції вартості шаблону Micro Fro...
OdessaJS Conf
 
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
Steve Lange
 

Was ist angesagt? (20)

Fast end-to-end-tests
Fast end-to-end-testsFast end-to-end-tests
Fast end-to-end-tests
 
Overview the Challenges and Limitations of Android App Automation with Espres...
Overview the Challenges and Limitations of Android App Automation with Espres...Overview the Challenges and Limitations of Android App Automation with Espres...
Overview the Challenges and Limitations of Android App Automation with Espres...
 
Automated Performance Testing
Automated Performance TestingAutomated Performance Testing
Automated Performance Testing
 
Introduction to Automated Testing
Introduction to Automated TestingIntroduction to Automated Testing
Introduction to Automated Testing
 
Игорь Бондаренко (Neklo) - Организация процесса разработки модулей для Magento
Игорь Бондаренко (Neklo) - Организация процесса разработки модулей для MagentoИгорь Бондаренко (Neklo) - Организация процесса разработки модулей для Magento
Игорь Бондаренко (Neklo) - Организация процесса разработки модулей для Magento
 
Максим Климишин "Що такого особливого у пропозиції вартості шаблону Micro Fro...
Максим Климишин "Що такого особливого у пропозиції вартості шаблону Micro Fro...Максим Климишин "Що такого особливого у пропозиції вартості шаблону Micro Fro...
Максим Климишин "Що такого особливого у пропозиції вартості шаблону Micro Fro...
 
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
 
Agile and test driven development
Agile and test driven developmentAgile and test driven development
Agile and test driven development
 
Why agile?
Why agile?Why agile?
Why agile?
 
Eclipse Day India 2015 - Eclipse RCP testing using Jubula based automation
Eclipse Day India 2015 - Eclipse RCP testing using Jubula based automationEclipse Day India 2015 - Eclipse RCP testing using Jubula based automation
Eclipse Day India 2015 - Eclipse RCP testing using Jubula based automation
 
Notes On Agile Development
Notes On Agile DevelopmentNotes On Agile Development
Notes On Agile Development
 
How to Introduce Continuous Delivery
How to Introduce Continuous DeliveryHow to Introduce Continuous Delivery
How to Introduce Continuous Delivery
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven Development
 
[AI series Talk #2] From PoC to Production - A Case Study
[AI series Talk #2] From PoC to Production - A Case Study[AI series Talk #2] From PoC to Production - A Case Study
[AI series Talk #2] From PoC to Production - A Case Study
 
Test driven development in meteor
Test driven development in meteorTest driven development in meteor
Test driven development in meteor
 
Introduction to Continuous Delivery (BBWorld/DevCon 2013)
Introduction to Continuous Delivery (BBWorld/DevCon 2013)Introduction to Continuous Delivery (BBWorld/DevCon 2013)
Introduction to Continuous Delivery (BBWorld/DevCon 2013)
 
What if you could eliminate the hidden costs of development?
What if you could eliminate the hidden costs of development?What if you could eliminate the hidden costs of development?
What if you could eliminate the hidden costs of development?
 
Emily Bache - Readable, Executable Requirements: Hands-On - EuroSTAR 2013
Emily Bache - Readable, Executable Requirements: Hands-On - EuroSTAR 2013Emily Bache - Readable, Executable Requirements: Hands-On - EuroSTAR 2013
Emily Bache - Readable, Executable Requirements: Hands-On - EuroSTAR 2013
 
Continuous Delivery
Continuous DeliveryContinuous Delivery
Continuous Delivery
 
Droid con 2013 workshop unit testing in android [robolectirc]
Droid con 2013 workshop   unit testing in android [robolectirc]Droid con 2013 workshop   unit testing in android [robolectirc]
Droid con 2013 workshop unit testing in android [robolectirc]
 

Ähnlich wie Page Objects - You're Doing it Wrong by Titus Fortner

An Overview of automated testing (1)
An Overview of automated testing (1)An Overview of automated testing (1)
An Overview of automated testing (1)
Rodrigo Lopes
 
Getting started with dev tools (atl)
Getting started with dev tools (atl)Getting started with dev tools (atl)
Getting started with dev tools (atl)
Thinkful
 

Ähnlich wie Page Objects - You're Doing it Wrong by Titus Fortner (20)

Everything you need to know about Associate Android Developer
Everything you need to know about Associate Android DeveloperEverything you need to know about Associate Android Developer
Everything you need to know about Associate Android Developer
 
An Overview of automated testing (1)
An Overview of automated testing (1)An Overview of automated testing (1)
An Overview of automated testing (1)
 
Demise of test scripts rise of test ideas
Demise of test scripts rise of test ideasDemise of test scripts rise of test ideas
Demise of test scripts rise of test ideas
 
React more than just components
React   more than just componentsReact   more than just components
React more than just components
 
Making cross browser tests beautiful
Making cross browser tests beautifulMaking cross browser tests beautiful
Making cross browser tests beautiful
 
React learning in the hard way
React   learning in the hard wayReact   learning in the hard way
React learning in the hard way
 
Four Stages of Automated Testing by Bradley Temple
Four Stages of Automated Testing by Bradley TempleFour Stages of Automated Testing by Bradley Temple
Four Stages of Automated Testing by Bradley Temple
 
Software Development Whats & Whys
Software Development Whats & Whys Software Development Whats & Whys
Software Development Whats & Whys
 
Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...
Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...
Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...
 
Lessons Learned When Automating
Lessons Learned When AutomatingLessons Learned When Automating
Lessons Learned When Automating
 
Getting started with dev tools (atl)
Getting started with dev tools (atl)Getting started with dev tools (atl)
Getting started with dev tools (atl)
 
Django production
Django productionDjango production
Django production
 
Peep Laja - Strategy - Conversion Hotel 2015
Peep Laja - Strategy - Conversion Hotel 2015Peep Laja - Strategy - Conversion Hotel 2015
Peep Laja - Strategy - Conversion Hotel 2015
 
Web stats
Web statsWeb stats
Web stats
 
Black Ops Testing Workshop from Agile Testing Days 2014
Black Ops Testing Workshop from Agile Testing Days 2014Black Ops Testing Workshop from Agile Testing Days 2014
Black Ops Testing Workshop from Agile Testing Days 2014
 
Get it right the first time through cheap and easy DIY usability testing
Get it right the first time through cheap and easy DIY usability testingGet it right the first time through cheap and easy DIY usability testing
Get it right the first time through cheap and easy DIY usability testing
 
Get it right the first time through cheap and easy DIY usability testing
Get it right the first time through cheap and easy DIY usability testingGet it right the first time through cheap and easy DIY usability testing
Get it right the first time through cheap and easy DIY usability testing
 
Learn Data Science
Learn Data ScienceLearn Data Science
Learn Data Science
 
Better Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component PatternBetter Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component Pattern
 
Destination Documentation: How Not to Get Lost in Your Org
Destination Documentation: How Not to Get Lost in Your OrgDestination Documentation: How Not to Get Lost in Your Org
Destination Documentation: How Not to Get Lost in Your Org
 

Mehr von Sauce Labs

Your Framework for Success: introduction to JavaScript Testing at Scale
Your Framework for Success: introduction to JavaScript Testing at ScaleYour Framework for Success: introduction to JavaScript Testing at Scale
Your Framework for Success: introduction to JavaScript Testing at Scale
Sauce Labs
 
Automating Hybrid Applications with Appium
Automating Hybrid Applications with AppiumAutomating Hybrid Applications with Appium
Automating Hybrid Applications with Appium
Sauce Labs
 
Quality at Speed: More API Testing, Less UI Testing
Quality at Speed: More API Testing, Less UI TestingQuality at Speed: More API Testing, Less UI Testing
Quality at Speed: More API Testing, Less UI Testing
Sauce Labs
 
Creating Digital Confidence with Test Automation
Creating Digital Confidence with Test AutomationCreating Digital Confidence with Test Automation
Creating Digital Confidence with Test Automation
Sauce Labs
 

Mehr von Sauce Labs (20)

Simplify Salesforce Testing with AI-Driven Codeless Tools
Simplify Salesforce Testing with AI-Driven Codeless ToolsSimplify Salesforce Testing with AI-Driven Codeless Tools
Simplify Salesforce Testing with AI-Driven Codeless Tools
 
Testing on Mobile Devices with Location Services
Testing on Mobile Devices with Location ServicesTesting on Mobile Devices with Location Services
Testing on Mobile Devices with Location Services
 
Your Framework for Success: introduction to JavaScript Testing at Scale
Your Framework for Success: introduction to JavaScript Testing at ScaleYour Framework for Success: introduction to JavaScript Testing at Scale
Your Framework for Success: introduction to JavaScript Testing at Scale
 
Automating Hybrid Applications with Appium
Automating Hybrid Applications with AppiumAutomating Hybrid Applications with Appium
Automating Hybrid Applications with Appium
 
Quality at Speed: More API Testing, Less UI Testing
Quality at Speed: More API Testing, Less UI TestingQuality at Speed: More API Testing, Less UI Testing
Quality at Speed: More API Testing, Less UI Testing
 
Creating Digital Confidence with Test Automation
Creating Digital Confidence with Test AutomationCreating Digital Confidence with Test Automation
Creating Digital Confidence with Test Automation
 
Just Enough (Automated) Testing
Just Enough (Automated) TestingJust Enough (Automated) Testing
Just Enough (Automated) Testing
 
Using Axe to Add Accessibility Checks to Your Existing Selenium Tests
Using Axe to Add Accessibility Checks to Your Existing Selenium TestsUsing Axe to Add Accessibility Checks to Your Existing Selenium Tests
Using Axe to Add Accessibility Checks to Your Existing Selenium Tests
 
How Open Source Helps to Bring Back Product Obsession
How Open Source Helps to Bring Back Product ObsessionHow Open Source Helps to Bring Back Product Obsession
How Open Source Helps to Bring Back Product Obsession
 
Webinar: A Sneak Peek at Selenium 4 with Simon Stewart
Webinar: A Sneak Peek at Selenium 4 with Simon StewartWebinar: A Sneak Peek at Selenium 4 with Simon Stewart
Webinar: A Sneak Peek at Selenium 4 with Simon Stewart
 
[Deu] Test Automatisierung Mit Web Driver.io
[Deu] Test Automatisierung Mit Web Driver.io[Deu] Test Automatisierung Mit Web Driver.io
[Deu] Test Automatisierung Mit Web Driver.io
 
Accelerating Innovation: Leveraging Open Source to Optimize Your Shift-Left I...
Accelerating Innovation: Leveraging Open Source to Optimize Your Shift-Left I...Accelerating Innovation: Leveraging Open Source to Optimize Your Shift-Left I...
Accelerating Innovation: Leveraging Open Source to Optimize Your Shift-Left I...
 
Accelerating Your Digital Agenda with Continuous Testing ft. Forrester
Accelerating Your Digital Agenda with Continuous Testing ft. ForresterAccelerating Your Digital Agenda with Continuous Testing ft. Forrester
Accelerating Your Digital Agenda with Continuous Testing ft. Forrester
 
How to Measure Success in Continuous Testing
How to Measure Success in Continuous TestingHow to Measure Success in Continuous Testing
How to Measure Success in Continuous Testing
 
From Zero to 2.7 Million - How Verizon Media Embraced Open Source to Accelera...
From Zero to 2.7 Million - How Verizon Media Embraced Open Source to Accelera...From Zero to 2.7 Million - How Verizon Media Embraced Open Source to Accelera...
From Zero to 2.7 Million - How Verizon Media Embraced Open Source to Accelera...
 
5 Steps to Jump Start Your Test Automation
5 Steps to Jump Start Your Test Automation5 Steps to Jump Start Your Test Automation
5 Steps to Jump Start Your Test Automation
 
Sauce Labs Webinar: Rising Importance of Software Testing
Sauce Labs Webinar: Rising Importance of Software TestingSauce Labs Webinar: Rising Importance of Software Testing
Sauce Labs Webinar: Rising Importance of Software Testing
 
BDD With Selenide by Hima Bindu Peteti
BDD With Selenide by Hima Bindu PetetiBDD With Selenide by Hima Bindu Peteti
BDD With Selenide by Hima Bindu Peteti
 
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
 
Continuous Delivery for "Mature" Codebases by Melisa Benua
Continuous Delivery for "Mature" Codebases by Melisa BenuaContinuous Delivery for "Mature" Codebases by Melisa Benua
Continuous Delivery for "Mature" Codebases by Melisa Benua
 

Kürzlich hochgeladen

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
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Kürzlich hochgeladen (20)

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
%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
 
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
 
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
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
%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
 
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
 
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
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
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
 
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...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
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
 
%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
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
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
 

Page Objects - You're Doing it Wrong by Titus Fortner

  • 1. Page Objects: You’re Doing It Wrong #badpageobject Titus Fortner Sr Solution Architect at Sauce Labs @titusfortner
  • 2. 2 • @titusfortner • Former SDET • Open Source • Senior Solution Architect at Sauce Labs! © Sauce Labs, Inc. Titus Fortner
  • 3. Ground Rules 1. “My Opinions Are Correct” 2. I have too many a lot of Opinions 3. Make Informed Decisions
  • 4. Law of the Instrument ● You Can Make Anything “Work” ○ How long for a new employee to understand? ○ How long for your replacement to understand? ○ Have you considered alternatives?
  • 5. My Priors ● End to End DOM to Database ● Scalable Test Automation Requires Tests be ○ Atomic, Autonomous, and Short ● Optimize Maintainability not “Correctness” ● Prefer Simple/Clear to Easy/Fast
  • 6. A Page Object is… an object oriented class that stores information about the services provided by a specific view in an application’s User Interface. ● Browser vs Mobile App ● Desktop Browser vs Mobile Browser ● Page / Modal / Section ● Action Methods & Element Definitions
  • 7. What Problems Do Page Objects Solve? ● Maintenance, Maintenance, Maintenance ● Separation of Concerns ● DRY A place for everything and everything in its place -Benjamin Franklin
  • 8. Conventions for Maintainability ● Consistency ● Principle of Least Surprise
  • 9. Page Object Critiques ● Abstract LESS! ○ YAGNI ○ Keep code base smaller by not over-abstracting ● Abstract MOAR! ○ Single Responsibility Principle ○ Keep classes smaller with more of them
  • 10. Page Object Principles ● Avoid Imperative ● Avoid Nondeterministic ● Avoid Complicated Constructors ● Avoid Coupling ● Avoid Assertions ● Avoid Ambivalence
  • 12. • How • Implementation Logic • Specific Details • All Data Declarative Imperative • What • Business Logic • Big Picture • Contextual Data
  • 15. Things That Encourage Imperative ● “Keyword Driven” Testing ○ Robot Framework ● “Data Driven” Testing (BDD?) ● Test Libraries with special matchers ○ Nightwatch.js ○ Site Prism gem ○ Selenide jar ● Property Files
  • 17. Checking State for Flow Control • Synchronization Issues • Your Test “Already Knows” • What driver are you using? • What Config determined the driver?
  • 18. Subclass / Factory / Interface
  • 20. Validating State in Constructor ● Good Idea – User shouldn’t care how state is set to arrive on the page
  • 21. What Your Users Will Do… ● Relying on “Magic” things in Insufficient Places is Less Clear
  • 22. Page Object Should Know Where it Lives ● Implement a visit method to be explicit • Re-use instead of Re-implementing • Be Direct!
  • 25. Fluent Pattern ● Errors are not captured at compile time ● Debuggers / Stack Trace inaccuracies ● Weird Names to make fun sentences in your code ● Subclasses must explicitly define all return values from the fluent interface
  • 26. PO Pattern Specific Objections ● Code repeatability: Options for re-using a LogIn Modal from Cart & Home Page? ○ Different Classes? Methods? ○ Intermittently skip returning instance values ● Your Deterministic test “Already Knows” what it is doing; ○ Don’t store the same information in multiple places ● Is the Return Value Obvious? ● “Visit” method provide state ● Atomic test theoretically only needs one Page Object
  • 29. Intention I Have Evaluated the “Functionality I Care About” and Have Determined that it: is / is not Working as Intended Vs I am unable to evaluate whether the “Functionality I Care About” is working as intended
  • 31. do Consider Method Intent do not Use Ambivalent Methods 6
  • 33. Unhelpful Information Not finding an element isn’t the real problem Some previous step unsuccessful
  • 35. Anti-Patterns that didn’t make the cut ● Don’t rely on standard Error Messages ● Use Additional Classes to avoid overloading the Base Page ● Avoid too many levels of subclass ● Allow a Page Object to define ”success” as an implementation detail ● Avoid Multiple Inheritance ● Avoid Soft Assertions ● Don’t Define Methods & Elements that you don’t already have a test for ● Do not look for the absence of an element ● All Reusability needs to exist in Page Object not in Steps / Test Code
  • 36. How About You? Tweet at me @titusfortner Your Bad Page Object Experiences #badpageobject