SlideShare a Scribd company logo
Designing for the Internet
Page Objects for the Real World
Intro
| Christopher Livett – Solution Architect
| Working with QualiTest UK for 8 years
| Specialist in test automation, performance
testing and leading technical delivery
| Helped define and implement numerous
test automation solutions using a variety of
tools, frameworks and languages
| Experienced in implementing Continuous
Integration, Continuous Delivery and
DevOps processes.
2
Introducing the Page Object Model
3
What is a
Page Object
Model?
| A pattern for modeling the UI components of an application as
objects to be consumed by test code
| Provides the test with a representation of the services offered
by a page
| Contains the deep knowledge of the structure of the HTML of
a page and its components
| Abstracts the test logic away from direct interaction with the
WebDriver API and System-Under-Test wherever possible.
4
Why Page
Object
Model?
| Expose page and component services rather than mechanics
| Write concise tests that exercise functionality, not technical
details
| Create maintainable tests by isolating the effect of UI change
on test code
| Produce readable tests by keeping implementation details out
of test code.
5
Layers of Abstraction
| Tests are comprised of steps
| Steps interact with pages
| Pages provide services and key components
| Operations on pages occur without any
knowledge of page structure
| Pages are comprised of elements
| Each element represents a single item on
a page that can be interacted with
| Text, buttons, fields, images, etc.
6
Steps
Pages
Elements
Tests
Design Considerations
| PageObject base class
| Interface with Selenium’s PageObjectFactory
| Provides easy access to the WebDriver
instance it is created with
| Optionally provision for detecting that the page
has loaded properly
| All Page Objects should be derived from
this base class
| Not all pages should be represented in
their entirety by a Page Object.
| Components
| Web applications may consist of lots of
elements on a single page, or no clear
distinction of “pages”
| Instead of a Page Object representing a whole
page, it can represent a component on a page
| Judgement as to whether to use pages,
components, or both
| No Page Object should be “bigger than
your head”
| https://gist.github.com/RiverGlide/7718ab70f9
d1ee0eddbf8bcf95887555.
7
Page Object Model vs Screenplay Pattern
8
Page Object vs Screenplay
| Page Object
| Model for abstracting implementation from
logic
| Most commonly used standard in test
automation
| Has been used in very large, stable solutions
| Designed to reduce code duplication,
encourage code re-use and make tests more
maintainable
| Does not strictly follow SOLID principles.
| Screenplay
| Design pattern for writing human-readable
tests with layers of abstraction
| Comprised of:
• Actors – Who is using the system
• Tasks – What are they doing
• Actions – How are they going to do it
• Web Pages – Where are the elements they need
| Breaks Page Objects in to Actions and Web
Pages
| Adheres more closely to SOLID principles.
9
Page Object
vs
Screenplay
continued
| Purpose of today is not debate Page Object vs Screenplay
| Both have proven to be viable solutions for writing
maintainable automated tests
| Principles learned in writing good quality Page Objects can be
refactored into Screenplay tests.
10
11
Introducing
| Demonstrating the Page Object model requires a testing
framework
| Serenity is an open source Java (and recently JavaScript)
library to speed up writing tests; including:
| Complete WebDriver testing framework
| Parallel execution of tests using JUnit, Cucumber or JBehave
| Integration with SauceLabs, Jira, and other testing tools
| Detailed reporting
| Supports both the Page Object and Screenplay pattern
| Well used across the industry.
12
Creating our first test
| Introducing creating a Serenity test from
scratch
| Test:
| Given I start on the form authentication page
When I log in as Tom Smith
Then I see the secure area
| Framework:
| Serenity, Selenium, JUnit and Maven
| Execute on single Chrome instance
| Hard-coded test data
13
Steps
FormAuthenticationSteps
Pages
FormAuthenticationPage
SecureAreaPage
Elements
usernameField
passwordField
etc.
Test
FormAuthentication
Demonstration 1:
Creating the authentication test
14
Challenging Page Object Models
15
Tables
| Common tasks
| Iteration
| Query for rows
| Sorting
| Row actions (like clicking edit or delete
buttons)
| Common Challenges
| Lack of unique identifiers
| Lack of relationships between column headers
and cells within rows
| Index and other related math can make code
messy.
16
Potential
Solutions
| Complex CSS or XPATH for finding data
| E.g. //table[@id=’table1']//tr[td//text()[contains(., '{0}')]]/td[3]
| Fast, re-usable and can be extended to find data within the table
| Difficult to create, read and update on change
| Parse whole table
| Cycle through each row, storing all data in to the ‘Row’ object
| Table object can then be stored and passed around to be usable by
code
| Slow to do 1st capture and requires re-capture on change
| Easy to use, understand, update
| Row iterator
| Similar to parsing whole table
| Parse row-by-row as needed until needed data found
| Speed depends on how much data is required.
17
Demonstration 2:
Table row iterator
18
Frames
| Common tasks
| Interacting with nested frames
| Interacting with iFrames
| Switching between pages and frames
| Common Challenges
| Frames can be from different sources
| iFrames may need to be loaded
| Needing to move back outside of frames.
19
Demonstration 3:
Handling iFrames
20
Dynamic Pages
| Many systems are dynamic by nature
| Thick client (Angular, JQuery)
| CMS
| Systems may not be made with testing in
mind
| Common Challenges
| IDs and classes may change each page load
or change
| Elements may move on the page
| Tests may change the page for other tests.
21
Demonstration 4:
Changing Buttons
22
JQuery
| JQuery and similar libraries introduce
complex behaviours to websites
| Almost endless possibility of features that
can prove challenging for test automation
| Common Challenges
| Lazy loading / infinite scrolling
| Hover actions
| Hidden elements
23
Demonstration 5:
Mouse-over elements and file downloads
24
Demonstration 6:
Infinite Scroll
25
HTML5 Video Player
| Common Tasks
| Play
| Pause
| Control volume
| Seeking
| Reload video
| Checking state
| Common challenges
| Video controls may not be interacted with by
WebDriver
| Controls may have difficult to identify selectors
| Videos may be in different states.
26
Demonstration 6:
Controlling YouTube videos
27
Conclusion
| We have shown one solution to each problem
| Different websites and situations may require different
solutions
| Complex pages could and should be broken into
‘Components’
| Page Objects may not be the perfect solution
| Easily become large and complex
| Can be difficult to maintain
| Break SOLID principles
| but:
| They provide abstraction of logic and implementation
| Allow creating unique solutions to unique problems
| Can be easily understood, created and updated.
28
29
www.QualiTestGroup.com
Thank You

More Related Content

PPTX
Webinar: How to get localization and testing for medical devices done right
PPTX
Model-Based Testing for ALM Octane: Better tests, built faster
PDF
DOES14 - Stephen Elliot - IDC - Delivering DevOps Business Metrics that Matter
PPTX
Mobility Trends | Customer Conversation Deck
PPT
JDA: Building an Open Source Center of Excellence
PDF
IBM Innovate - Uderstanding DevOps
PDF
IBM DevOps Enabling continuous integration & delivery
PDF
Testing Comes into its Own in DevOps by Jack Maher
Webinar: How to get localization and testing for medical devices done right
Model-Based Testing for ALM Octane: Better tests, built faster
DOES14 - Stephen Elliot - IDC - Delivering DevOps Business Metrics that Matter
Mobility Trends | Customer Conversation Deck
JDA: Building an Open Source Center of Excellence
IBM Innovate - Uderstanding DevOps
IBM DevOps Enabling continuous integration & delivery
Testing Comes into its Own in DevOps by Jack Maher

What's hot (20)

PDF
DevOps the Big Picture for Testers by Joseph Ours
PPTX
Delivering Java Applications? Ensure Top Performance Every Time, with Intell...
PDF
How-To-Guide for Software Security Vulnerability Remediation
PDF
DevOps adoption in the enterprise
PPTX
Maturing your path toward DevOps with Continuous Testing
PPTX
End to-End Monitoring for ITSM and DevOps
PPTX
DevopsBusinessCaseTemplate
PDF
Automating API Generation and DevOps Pipeline for On-Prem Systems
PDF
DevOps Workshop - Addressing Quality Challenges of Highly Complex and Integra...
PPTX
DevOps 101 - IBM Impact 2014
PPTX
SF Chaos Engineering Meetup: Building Disaster Recovery via Resilience Engine...
PDF
What is DevOps? - ITSM Academy Webinar
PPTX
Continuous Delivery Maturity Model
PDF
Enterprise DevOps Adoption LinkedIn
PDF
Introduction to DevOps
PPTX
Why DevOps Matters To The CIO
PDF
XebiaLabs Overview Slides
PPTX
Introduction to DevOps
PPTX
Easily Create Scalable Automation using Selenium
PPTX
The Evolution of Application Release Automation
DevOps the Big Picture for Testers by Joseph Ours
Delivering Java Applications? Ensure Top Performance Every Time, with Intell...
How-To-Guide for Software Security Vulnerability Remediation
DevOps adoption in the enterprise
Maturing your path toward DevOps with Continuous Testing
End to-End Monitoring for ITSM and DevOps
DevopsBusinessCaseTemplate
Automating API Generation and DevOps Pipeline for On-Prem Systems
DevOps Workshop - Addressing Quality Challenges of Highly Complex and Integra...
DevOps 101 - IBM Impact 2014
SF Chaos Engineering Meetup: Building Disaster Recovery via Resilience Engine...
What is DevOps? - ITSM Academy Webinar
Continuous Delivery Maturity Model
Enterprise DevOps Adoption LinkedIn
Introduction to DevOps
Why DevOps Matters To The CIO
XebiaLabs Overview Slides
Introduction to DevOps
Easily Create Scalable Automation using Selenium
The Evolution of Application Release Automation
Ad

Similar to Designing for the internet - Page Objects for the Real World (20)

PDF
Accessibility Testing - Using Asqatasun - Meetup Webinar
PPTX
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
PPT
Test Automation Framework Development Introduction
PPTX
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
DOC
Priyanka_3.5years_Resume
DOC
Mayur_Resume (2) (1)
PPTX
Better Page Object Handling with Loadable Component Pattern
PPTX
Web Engineering: A Practitioner Approach -Testing web app - Content Managemen...
PPT
Designing a Test Automation Framework By Quontra solutions
PDF
Better Page Object Handling with Loadable Component Pattern - SQA Days 20, Be...
PPT
Test Automation Framework Online Training by QuontraSolutions
PPTX
WebMate: A Tool for Testing Web 2.0 Applications
PPTX
Automated Testing Of EPiServer CMS Sites
PPTX
Web and load testing with Visual Studio 2010 Ultimate
PDF
Better Page Object Handling with Loadable Component Pattern
PPTX
QAorHighway2016
PPTX
An Introduction to Web Components
PPTX
An easy way to automate complex UI
PPTX
Test Automation Architecture That Works by Bhupesh Dahal
PDF
Introduction to Protractor
Accessibility Testing - Using Asqatasun - Meetup Webinar
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
Test Automation Framework Development Introduction
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
Priyanka_3.5years_Resume
Mayur_Resume (2) (1)
Better Page Object Handling with Loadable Component Pattern
Web Engineering: A Practitioner Approach -Testing web app - Content Managemen...
Designing a Test Automation Framework By Quontra solutions
Better Page Object Handling with Loadable Component Pattern - SQA Days 20, Be...
Test Automation Framework Online Training by QuontraSolutions
WebMate: A Tool for Testing Web 2.0 Applications
Automated Testing Of EPiServer CMS Sites
Web and load testing with Visual Studio 2010 Ultimate
Better Page Object Handling with Loadable Component Pattern
QAorHighway2016
An Introduction to Web Components
An easy way to automate complex UI
Test Automation Architecture That Works by Bhupesh Dahal
Introduction to Protractor
Ad

More from Qualitest (20)

PDF
10 must do’s for perfect customer experience (Cx) -Qualitest
PPTX
Don’t Let Missed Bugs Cause Mayhem in your Organization!
PPTX
DevOps and Groupthink An Oxymoron?
PPTX
Google SLS Outsourcing by Jeffrey Roth
PPTX
Successful Offshore Practices by Ofer Glanz
PPTX
Pricing Models by Michel Sharvit
PPTX
5 keys to success at MTS by Tzahi Falkovich
PPTX
The Journey of QualiTest by Ayal Zylberman
PPTX
DevSecOps - It can change your life (cycle)
PPTX
IoT Quality Challenges - Testing & Engineering
PPTX
Webinar: DevOps challenges facing QA
PPTX
Root Cause Analysis | QualiTest Group
PPTX
Testing for a Great App and Web Experience | QualiTest Group
PPTX
DevOps 101
PPTX
Killing the Myths of Outsourced Software Testing
PPTX
Why do we need a Scrum Master?
PPTX
How to Test Big Data Systems | QualiTest Group
PPTX
The changing role of a QA | QualiTest Group
PPTX
Roaming Assurance | QualiTest Group
PPTX
Crowd Catcher: Take control of the Crowd (part 1 of 3) | QualiTest Group
10 must do’s for perfect customer experience (Cx) -Qualitest
Don’t Let Missed Bugs Cause Mayhem in your Organization!
DevOps and Groupthink An Oxymoron?
Google SLS Outsourcing by Jeffrey Roth
Successful Offshore Practices by Ofer Glanz
Pricing Models by Michel Sharvit
5 keys to success at MTS by Tzahi Falkovich
The Journey of QualiTest by Ayal Zylberman
DevSecOps - It can change your life (cycle)
IoT Quality Challenges - Testing & Engineering
Webinar: DevOps challenges facing QA
Root Cause Analysis | QualiTest Group
Testing for a Great App and Web Experience | QualiTest Group
DevOps 101
Killing the Myths of Outsourced Software Testing
Why do we need a Scrum Master?
How to Test Big Data Systems | QualiTest Group
The changing role of a QA | QualiTest Group
Roaming Assurance | QualiTest Group
Crowd Catcher: Take control of the Crowd (part 1 of 3) | QualiTest Group

Recently uploaded (20)

PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Essential Infomation Tech presentation.pptx
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Introduction to Artificial Intelligence
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
history of c programming in notes for students .pptx
PDF
System and Network Administraation Chapter 3
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Digital Strategies for Manufacturing Companies
Operating system designcfffgfgggggggvggggggggg
Essential Infomation Tech presentation.pptx
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Introduction to Artificial Intelligence
Odoo Companies in India – Driving Business Transformation.pdf
PTS Company Brochure 2025 (1).pdf.......
Understanding Forklifts - TECH EHS Solution
history of c programming in notes for students .pptx
System and Network Administraation Chapter 3
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
wealthsignaloriginal-com-DS-text-... (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Wondershare Filmora 15 Crack With Activation Key [2025
How to Migrate SBCGlobal Email to Yahoo Easily
Digital Strategies for Manufacturing Companies

Designing for the internet - Page Objects for the Real World

  • 1. Designing for the Internet Page Objects for the Real World
  • 2. Intro | Christopher Livett – Solution Architect | Working with QualiTest UK for 8 years | Specialist in test automation, performance testing and leading technical delivery | Helped define and implement numerous test automation solutions using a variety of tools, frameworks and languages | Experienced in implementing Continuous Integration, Continuous Delivery and DevOps processes. 2
  • 3. Introducing the Page Object Model 3
  • 4. What is a Page Object Model? | A pattern for modeling the UI components of an application as objects to be consumed by test code | Provides the test with a representation of the services offered by a page | Contains the deep knowledge of the structure of the HTML of a page and its components | Abstracts the test logic away from direct interaction with the WebDriver API and System-Under-Test wherever possible. 4
  • 5. Why Page Object Model? | Expose page and component services rather than mechanics | Write concise tests that exercise functionality, not technical details | Create maintainable tests by isolating the effect of UI change on test code | Produce readable tests by keeping implementation details out of test code. 5
  • 6. Layers of Abstraction | Tests are comprised of steps | Steps interact with pages | Pages provide services and key components | Operations on pages occur without any knowledge of page structure | Pages are comprised of elements | Each element represents a single item on a page that can be interacted with | Text, buttons, fields, images, etc. 6 Steps Pages Elements Tests
  • 7. Design Considerations | PageObject base class | Interface with Selenium’s PageObjectFactory | Provides easy access to the WebDriver instance it is created with | Optionally provision for detecting that the page has loaded properly | All Page Objects should be derived from this base class | Not all pages should be represented in their entirety by a Page Object. | Components | Web applications may consist of lots of elements on a single page, or no clear distinction of “pages” | Instead of a Page Object representing a whole page, it can represent a component on a page | Judgement as to whether to use pages, components, or both | No Page Object should be “bigger than your head” | https://gist.github.com/RiverGlide/7718ab70f9 d1ee0eddbf8bcf95887555. 7
  • 8. Page Object Model vs Screenplay Pattern 8
  • 9. Page Object vs Screenplay | Page Object | Model for abstracting implementation from logic | Most commonly used standard in test automation | Has been used in very large, stable solutions | Designed to reduce code duplication, encourage code re-use and make tests more maintainable | Does not strictly follow SOLID principles. | Screenplay | Design pattern for writing human-readable tests with layers of abstraction | Comprised of: • Actors – Who is using the system • Tasks – What are they doing • Actions – How are they going to do it • Web Pages – Where are the elements they need | Breaks Page Objects in to Actions and Web Pages | Adheres more closely to SOLID principles. 9
  • 10. Page Object vs Screenplay continued | Purpose of today is not debate Page Object vs Screenplay | Both have proven to be viable solutions for writing maintainable automated tests | Principles learned in writing good quality Page Objects can be refactored into Screenplay tests. 10
  • 11. 11
  • 12. Introducing | Demonstrating the Page Object model requires a testing framework | Serenity is an open source Java (and recently JavaScript) library to speed up writing tests; including: | Complete WebDriver testing framework | Parallel execution of tests using JUnit, Cucumber or JBehave | Integration with SauceLabs, Jira, and other testing tools | Detailed reporting | Supports both the Page Object and Screenplay pattern | Well used across the industry. 12
  • 13. Creating our first test | Introducing creating a Serenity test from scratch | Test: | Given I start on the form authentication page When I log in as Tom Smith Then I see the secure area | Framework: | Serenity, Selenium, JUnit and Maven | Execute on single Chrome instance | Hard-coded test data 13 Steps FormAuthenticationSteps Pages FormAuthenticationPage SecureAreaPage Elements usernameField passwordField etc. Test FormAuthentication
  • 14. Demonstration 1: Creating the authentication test 14
  • 16. Tables | Common tasks | Iteration | Query for rows | Sorting | Row actions (like clicking edit or delete buttons) | Common Challenges | Lack of unique identifiers | Lack of relationships between column headers and cells within rows | Index and other related math can make code messy. 16
  • 17. Potential Solutions | Complex CSS or XPATH for finding data | E.g. //table[@id=’table1']//tr[td//text()[contains(., '{0}')]]/td[3] | Fast, re-usable and can be extended to find data within the table | Difficult to create, read and update on change | Parse whole table | Cycle through each row, storing all data in to the ‘Row’ object | Table object can then be stored and passed around to be usable by code | Slow to do 1st capture and requires re-capture on change | Easy to use, understand, update | Row iterator | Similar to parsing whole table | Parse row-by-row as needed until needed data found | Speed depends on how much data is required. 17
  • 19. Frames | Common tasks | Interacting with nested frames | Interacting with iFrames | Switching between pages and frames | Common Challenges | Frames can be from different sources | iFrames may need to be loaded | Needing to move back outside of frames. 19
  • 21. Dynamic Pages | Many systems are dynamic by nature | Thick client (Angular, JQuery) | CMS | Systems may not be made with testing in mind | Common Challenges | IDs and classes may change each page load or change | Elements may move on the page | Tests may change the page for other tests. 21
  • 23. JQuery | JQuery and similar libraries introduce complex behaviours to websites | Almost endless possibility of features that can prove challenging for test automation | Common Challenges | Lazy loading / infinite scrolling | Hover actions | Hidden elements 23
  • 24. Demonstration 5: Mouse-over elements and file downloads 24
  • 26. HTML5 Video Player | Common Tasks | Play | Pause | Control volume | Seeking | Reload video | Checking state | Common challenges | Video controls may not be interacted with by WebDriver | Controls may have difficult to identify selectors | Videos may be in different states. 26
  • 28. Conclusion | We have shown one solution to each problem | Different websites and situations may require different solutions | Complex pages could and should be broken into ‘Components’ | Page Objects may not be the perfect solution | Easily become large and complex | Can be difficult to maintain | Break SOLID principles | but: | They provide abstraction of logic and implementation | Allow creating unique solutions to unique problems | Can be easily understood, created and updated. 28
  • 29. 29

Editor's Notes

  • #15: - Start with a blank framework - Begin by pages only having ‘enterUsername’, ’enterPassword’ and ‘submit’ methods, later refactor to include ’authenticate’ method which performs all three - Create test, implement first step, implement page, execute implement next step, implement pages, execute, repeat - Talk through aspects of the test - Show report once test fully passing
  • #19: - Create a Row class within the Table page - Create a method to get all row elements by FindElements - Create a method to get an individual user by passing in each rowElement 1-by-1 and returning the found row - Show complete page object being used in tests