SlideShare uma empresa Scribd logo
1 de 34
Using the Page Object
                       Pattern to Improve
                  Functional Test Maintainability
                            Dante Briones
                                Principal Consultant
                              Electronic Ingenuity LLC
                           http://electronicingenuity.com




Friday, 07 August, 2009
The Page Object Pattern

                     • Technique for structuring test code that:
                      • Promotes reuse and reduces duplication
                      • Makes tests readable
                      • Makes tests more robust (less brittle)
                      • Improves maintainability, particularly if
                          the application is rapidly evolving


Friday, 07 August, 2009
The Page Object Pattern

                     • Demos will be coded in Java
                     • Everything we discuss is applicable to other
                          strongly-typed languages (e.g. C#)
                     • Most things are applicable to dynamically-
                          typed languages (e.g. Ruby, Python, Perl)



Friday, 07 August, 2009
Selenium IDE
                                     Quick Poll


                     • How many using Se IDE?
                     • How many create tests primarily through
                          record & playback?




Friday, 07 August, 2009
Selenium IDE
                               It’s Great Because:

                     • It’s Free
                     • It’s Free
                     • Requires little or no programming
                          experience




Friday, 07 August, 2009
Selenium IDE
                           It falls short because:

                     • Selenese is not a programming language
                      • No support for loops/iteration
                      • No support for conditionals (if...else)
                      • No way to eliminate duplicated code!

Friday, 07 August, 2009
Selenium IDE
                            Why is duplication bad?

                     • Has this ever happened to you?
                      • A tiny change to the app causes several
                            test failures?
                          • Let’s see an example


Friday, 07 August, 2009
Demo



Friday, 07 August, 2009
Selenium IDE
                           Why is duplication bad?


                     • Fixing the tests will require more work
                          than the change that caused the failure
                     • Duplication makes code less maintainable


Friday, 07 August, 2009
Selenium IDE
                                       Summary


                          • Great productivity for the first few tests
                          • Maintainability decreases as the test suite
                            grows
                          • How can we do better?

Friday, 07 August, 2009
Start Coding Your Tests
                                             a.k.a.
                          “Write tests in a programming language”




Friday, 07 August, 2009
Coding Your Tests
                                 Quick Poll



                     • How many are using Selenium RC?



Friday, 07 August, 2009
Coding Your Tests
                              How does this help?


                     • We can eliminate duplication by building
                          abstractions
                     • Let’s see an example of this


Friday, 07 August, 2009
Demo



Friday, 07 August, 2009
Coding Your Tests
                              What happens next?

                     • All commonly used methods get pulled into
                          the base class of all tests
                     • As the test suite grows, so does the base
                          class
                     • Uh oh...the base class starts getting too big

Friday, 07 August, 2009
Coding Your Tests
                              How Big is Too Big?

                     • You can’t tell someone else has already
                          written the code you’re about to write
                     • Frequent version control conflicts
                     • Maintenance is an issue again


Friday, 07 August, 2009
Coding Your Tests
                 How to rein in your base class?
                     • Observation: For any given page, most of
                          the behavior does not apply
                     • Example: you can’t change your password
                          on the “view cart” page
                     • What if we moved the page-specific
                          behavior into a corresponding class?
                     • Voila! The Page Object is born
Friday, 07 August, 2009
The Page Object



Friday, 07 August, 2009
The Page Object
                                What does it do?


                     • Consolidates the code for interacting with
                          any given UI element
                     • Allows you to model the UI in your tests

Friday, 07 August, 2009
The Page Object
                                 What does it do?
                     • Exposes methods that reflect the things a
                          user can see and do on that page, e.g.
                          • addItemToCart(), getPrice()
                          • getEntryTitle(), saveDraft(), publishEntry()
                     • Hides the details of telling the browser
                          how to do those things


Friday, 07 August, 2009
Demo



Friday, 07 August, 2009
The Page Object
                                     Results

                     • Test code is very readable
                     • No duplication of Selenium API calls
                     • Interactive documentation via Ctrl-Space
                     • Eminently reusable code

Friday, 07 August, 2009
The Page Object
                                        Results

                     • This technique is framework-agnostic
                      • Has been used with Selenium, WebDriver
                            (Selenium 2.0), Watir, and others
                          • I’ve even used it to drive desktop apps


Friday, 07 August, 2009
The Page Object
                                        Results

                     • Because it encapsulates the details of the
                          test framework API:
                          • You can use this technique to simplify the
                            process of swapping frameworks
                          • In theory, you only need to reimplement
                            the Page base class.



Friday, 07 August, 2009
But wait, there’s more!
                                   It gets better!

                     • Page Objects improve maintainability
                     • They also provide an opportunity to make
                          test creation extremely quick (and maybe
                          even fun!)
                     • How? Page Objects + Method Chaining

Friday, 07 August, 2009
Method Chaining
                          What’s method chaining?


                     • Change the signature of user behavior
                          methods so that they return the page
                          object itself
                     • Allows multiple behavior methods to be
                          called in sequence



Friday, 07 August, 2009
Method Chaining
                            What will it do for me?


                          • Removes for “code clutter”
                          • Tests become even more readable


Friday, 07 August, 2009
Method Chaining
                    How does it work in practice?
                     • All Page Object methods return a
                          reference to a Page Object
                          • If the “user action” moves the focus to a
                            different page, the method should return
                            that page object
                          • Otherwise, return the same page object
                     • Time for an example
Friday, 07 August, 2009
Demo



Friday, 07 August, 2009
Method Chaining
                                      Results


                     • Test code is even more readable
                     • Very quick to write
                     • (Actually kinda fun. Don’t tell anyone!)


Friday, 07 August, 2009
Method Chaining
                                       Caveats


                     • Dependent on tool support
                     • Lots of options: IntelliJ IDEA, Eclipse,
                          NetBeans, VisualStudio




Friday, 07 August, 2009
Method Chaining
                                       Caveats
                     • Tool support depends on language
                      • Excellent support for strongly typed
                            languages like Java and C#
                          • Support is “up and coming” for
                            dynamically typed languages (Ruby,
                            Python, and Perl)



Friday, 07 August, 2009
The Page Object Pattern
                     • Technique for organizing test code that:
                      • Promotes reuse and reduces duplication
                      • Makes tests readable
                      • Makes tests more robust (less brittle)
                      • Improves maintainability, particularly if
                            the application is rapidly evolving
                          • Is just as quick record & playback!
Friday, 07 August, 2009
Q &A



Friday, 07 August, 2009

Mais conteúdo relacionado

Mais procurados

Test Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEMTest Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEMSagar Sane
 
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.pptxMikalai Alimenkou
 
Automated Testing in Angular Slides
Automated Testing in Angular SlidesAutomated Testing in Angular Slides
Automated Testing in Angular SlidesJim Lynch
 
[Webinar] Continuous Testing Done Right: Test Automation at the World's Leadi...
[Webinar] Continuous Testing Done Right: Test Automation at the World's Leadi...[Webinar] Continuous Testing Done Right: Test Automation at the World's Leadi...
[Webinar] Continuous Testing Done Right: Test Automation at the World's Leadi...Applitools
 
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 PatternSargis Sargsyan
 
Selenium WebDriver - Test automation for web applications
Selenium WebDriver - Test automation for web applicationsSelenium WebDriver - Test automation for web applications
Selenium WebDriver - Test automation for web applicationsTSundberg
 
Patterns of a “good” test automation framework
Patterns of a “good” test automation frameworkPatterns of a “good” test automation framework
Patterns of a “good” test automation frameworkAnand Bagmar
 
Introduction To Web Application Testing
Introduction To Web Application TestingIntroduction To Web Application Testing
Introduction To Web Application TestingYnon Perek
 
Selenium Tips & Tricks
Selenium Tips & TricksSelenium Tips & Tricks
Selenium Tips & TricksDave Haeffner
 
UI Testing Automation
UI Testing AutomationUI Testing Automation
UI Testing AutomationAgileEngine
 
Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Brian Sam-Bodden
 
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 UIIvan Pashko
 
Test Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and MochaTest Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and MochaSalesforce Developers
 
Visual Automation Framework via Screenshot Comparison
Visual Automation Framework via Screenshot ComparisonVisual Automation Framework via Screenshot Comparison
Visual Automation Framework via Screenshot ComparisonMek Srunyu Stittri
 
Protractor end-to-end testing framework for angular js
Protractor   end-to-end testing framework for angular jsProtractor   end-to-end testing framework for angular js
Protractor end-to-end testing framework for angular jscodeandyou forums
 
Design patterns in test automation
Design patterns in test automationDesign patterns in test automation
Design patterns in test automationMikalai Alimenkou
 
Automation Frame works Instruction Sheet
Automation Frame works Instruction SheetAutomation Frame works Instruction Sheet
Automation Frame works Instruction SheetvodQA
 
Colorful world-of-visual-automation-testing-latest
Colorful world-of-visual-automation-testing-latestColorful world-of-visual-automation-testing-latest
Colorful world-of-visual-automation-testing-latestOnur Baskirt
 

Mais procurados (20)

Test Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEMTest Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEM
 
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
 
Automated Testing in Angular Slides
Automated Testing in Angular SlidesAutomated Testing in Angular Slides
Automated Testing in Angular Slides
 
Cucumber ppt
Cucumber pptCucumber ppt
Cucumber ppt
 
[Webinar] Continuous Testing Done Right: Test Automation at the World's Leadi...
[Webinar] Continuous Testing Done Right: Test Automation at the World's Leadi...[Webinar] Continuous Testing Done Right: Test Automation at the World's Leadi...
[Webinar] Continuous Testing Done Right: Test Automation at the World's Leadi...
 
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
 
Selenium WebDriver - Test automation for web applications
Selenium WebDriver - Test automation for web applicationsSelenium WebDriver - Test automation for web applications
Selenium WebDriver - Test automation for web applications
 
Patterns of a “good” test automation framework
Patterns of a “good” test automation frameworkPatterns of a “good” test automation framework
Patterns of a “good” test automation framework
 
Introduction To Web Application Testing
Introduction To Web Application TestingIntroduction To Web Application Testing
Introduction To Web Application Testing
 
Selenium Tips & Tricks
Selenium Tips & TricksSelenium Tips & Tricks
Selenium Tips & Tricks
 
UI Testing Automation
UI Testing AutomationUI Testing Automation
UI Testing Automation
 
Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 
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
 
Test Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and MochaTest Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and Mocha
 
Visual Automation Framework via Screenshot Comparison
Visual Automation Framework via Screenshot ComparisonVisual Automation Framework via Screenshot Comparison
Visual Automation Framework via Screenshot Comparison
 
Protractor end-to-end testing framework for angular js
Protractor   end-to-end testing framework for angular jsProtractor   end-to-end testing framework for angular js
Protractor end-to-end testing framework for angular js
 
Design patterns in test automation
Design patterns in test automationDesign patterns in test automation
Design patterns in test automation
 
Automation Frame works Instruction Sheet
Automation Frame works Instruction SheetAutomation Frame works Instruction Sheet
Automation Frame works Instruction Sheet
 
Colorful world-of-visual-automation-testing-latest
Colorful world-of-visual-automation-testing-latestColorful world-of-visual-automation-testing-latest
Colorful world-of-visual-automation-testing-latest
 

Destaque

Page Objects Done Right - selenium conference 2014
Page Objects Done Right - selenium conference 2014Page Objects Done Right - selenium conference 2014
Page Objects Done Right - selenium conference 2014Oren Rubin
 
Automation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAutomation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAlan Richardson
 
A journey beyond the page object pattern
A journey beyond the page object patternA journey beyond the page object pattern
A journey beyond the page object patternRiverGlide
 
DSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional testsDSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional testsMikalai Alimenkou
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework DesignsSauce Labs
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using SeleniumNaresh Chintalcheru
 
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...Alan Richardson
 
Software Estimation Techniques
Software Estimation TechniquesSoftware Estimation Techniques
Software Estimation Techniqueskamal
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object patternMichael Palotas
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Seleniumvivek_prahlad
 
Software cost estimation
Software cost estimationSoftware cost estimation
Software cost estimationdjview
 
Automation testing strategy, approach & planning
Automation testing  strategy, approach & planningAutomation testing  strategy, approach & planning
Automation testing strategy, approach & planningSivaprasanthRentala1975
 
Refactoring page objects The Screenplay Pattern
Refactoring page objects   The Screenplay Pattern Refactoring page objects   The Screenplay Pattern
Refactoring page objects The Screenplay Pattern RiverGlide
 
Advanced Selenium Workshop
Advanced Selenium WorkshopAdvanced Selenium Workshop
Advanced Selenium WorkshopClever Moe
 
Specifications For Enterprise Testing
Specifications For Enterprise TestingSpecifications For Enterprise Testing
Specifications For Enterprise TestingSathyan Sethumadhavan
 

Destaque (20)

Beyond Page Objects
Beyond Page ObjectsBeyond Page Objects
Beyond Page Objects
 
Page Objects Done Right - selenium conference 2014
Page Objects Done Right - selenium conference 2014Page Objects Done Right - selenium conference 2014
Page Objects Done Right - selenium conference 2014
 
Automation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAutomation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and Beyond
 
A journey beyond the page object pattern
A journey beyond the page object patternA journey beyond the page object pattern
A journey beyond the page object pattern
 
DSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional testsDSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional tests
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework Designs
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
Hands on Exploration of Page Objects and Abstraction Layers with Selenium Web...
 
Software Estimation Techniques
Software Estimation TechniquesSoftware Estimation Techniques
Software Estimation Techniques
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object pattern
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Selenium
 
Software cost estimation
Software cost estimationSoftware cost estimation
Software cost estimation
 
Automation testing strategy, approach & planning
Automation testing  strategy, approach & planningAutomation testing  strategy, approach & planning
Automation testing strategy, approach & planning
 
Refactoring page objects The Screenplay Pattern
Refactoring page objects   The Screenplay Pattern Refactoring page objects   The Screenplay Pattern
Refactoring page objects The Screenplay Pattern
 
Advanced Selenium Workshop
Advanced Selenium WorkshopAdvanced Selenium Workshop
Advanced Selenium Workshop
 
Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
 
Specifications For Enterprise Testing
Specifications For Enterprise TestingSpecifications For Enterprise Testing
Specifications For Enterprise Testing
 

Semelhante a Using The Page Object Pattern

PHPUnit & Continuous Integration: An Introduction
PHPUnit & Continuous Integration: An IntroductionPHPUnit & Continuous Integration: An Introduction
PHPUnit & Continuous Integration: An Introductionalexmace
 
Web Application Testing with Selenium
Web Application Testing with Selenium Web Application Testing with Selenium
Web Application Testing with Selenium Sargis Sargsyan
 
TLC2018 Shyam Sunder: Legoizing Testing
TLC2018 Shyam Sunder: Legoizing TestingTLC2018 Shyam Sunder: Legoizing Testing
TLC2018 Shyam Sunder: Legoizing TestingAnna Royzman
 
How To Make Your Testing More Groovy
How To Make Your Testing More GroovyHow To Make Your Testing More Groovy
How To Make Your Testing More GroovyCraig Smith
 
Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...SQALab
 
2011 JavaOne Apache TomEE Java EE 6 Web Profile
2011 JavaOne Apache TomEE Java EE 6 Web Profile2011 JavaOne Apache TomEE Java EE 6 Web Profile
2011 JavaOne Apache TomEE Java EE 6 Web ProfileDavid Blevins
 
Plone Testing Tools And Techniques
Plone Testing Tools And TechniquesPlone Testing Tools And Techniques
Plone Testing Tools And TechniquesJordan Baker
 
Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptTroy Miles
 
SVCC 2011 - 0 - 60: QA Automation @ Box
SVCC 2011 - 0 - 60: QA Automation @ BoxSVCC 2011 - 0 - 60: QA Automation @ Box
SVCC 2011 - 0 - 60: QA Automation @ BoxPeter White
 
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in DjangoDjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in DjangoCasey Kinsey
 
Sap inside track Munich 2017
Sap inside track Munich 2017Sap inside track Munich 2017
Sap inside track Munich 2017Rainer Winkler
 
Opticon 2017 How Developers Can Take Experimentation
Opticon 2017 How Developers Can Take ExperimentationOpticon 2017 How Developers Can Take Experimentation
Opticon 2017 How Developers Can Take ExperimentationOptimizely
 
Growing Trends of Open Source UI Frameworks
Growing Trends of Open Source UI FrameworksGrowing Trends of Open Source UI Frameworks
Growing Trends of Open Source UI FrameworksSmartBear
 
Test Driven Sysadmin
Test Driven SysadminTest Driven Sysadmin
Test Driven Sysadminjohanku
 
Web Test Automation Framework - IndicThreads Conference
Web Test Automation Framework  - IndicThreads ConferenceWeb Test Automation Framework  - IndicThreads Conference
Web Test Automation Framework - IndicThreads ConferenceIndicThreads
 
Why Your Selenium Tests are so Dang Brittle, and What to Do About It
Why Your Selenium Tests are so Dang Brittle, and What to Do About ItWhy Your Selenium Tests are so Dang Brittle, and What to Do About It
Why Your Selenium Tests are so Dang Brittle, and What to Do About ItJay Aho
 

Semelhante a Using The Page Object Pattern (20)

PHPUnit & Continuous Integration: An Introduction
PHPUnit & Continuous Integration: An IntroductionPHPUnit & Continuous Integration: An Introduction
PHPUnit & Continuous Integration: An Introduction
 
Web Application Testing with Selenium
Web Application Testing with Selenium Web Application Testing with Selenium
Web Application Testing with Selenium
 
TLC2018 Shyam Sunder: Legoizing Testing
TLC2018 Shyam Sunder: Legoizing TestingTLC2018 Shyam Sunder: Legoizing Testing
TLC2018 Shyam Sunder: Legoizing Testing
 
How To Make Your Testing More Groovy
How To Make Your Testing More GroovyHow To Make Your Testing More Groovy
How To Make Your Testing More Groovy
 
Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...
 
2011 JavaOne Apache TomEE Java EE 6 Web Profile
2011 JavaOne Apache TomEE Java EE 6 Web Profile2011 JavaOne Apache TomEE Java EE 6 Web Profile
2011 JavaOne Apache TomEE Java EE 6 Web Profile
 
Plone Testing Tools And Techniques
Plone Testing Tools And TechniquesPlone Testing Tools And Techniques
Plone Testing Tools And Techniques
 
Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScript
 
Useful automation
Useful automationUseful automation
Useful automation
 
FreshAir2008
FreshAir2008FreshAir2008
FreshAir2008
 
FreshAir2008
FreshAir2008FreshAir2008
FreshAir2008
 
SVCC 2011 - 0 - 60: QA Automation @ Box
SVCC 2011 - 0 - 60: QA Automation @ BoxSVCC 2011 - 0 - 60: QA Automation @ Box
SVCC 2011 - 0 - 60: QA Automation @ Box
 
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in DjangoDjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
 
Sap inside track Munich 2017
Sap inside track Munich 2017Sap inside track Munich 2017
Sap inside track Munich 2017
 
Opticon 2017 How Developers Can Take Experimentation
Opticon 2017 How Developers Can Take ExperimentationOpticon 2017 How Developers Can Take Experimentation
Opticon 2017 How Developers Can Take Experimentation
 
Growing Trends of Open Source UI Frameworks
Growing Trends of Open Source UI FrameworksGrowing Trends of Open Source UI Frameworks
Growing Trends of Open Source UI Frameworks
 
Test Driven Sysadmin
Test Driven SysadminTest Driven Sysadmin
Test Driven Sysadmin
 
Web Test Automation Framework - IndicThreads Conference
Web Test Automation Framework  - IndicThreads ConferenceWeb Test Automation Framework  - IndicThreads Conference
Web Test Automation Framework - IndicThreads Conference
 
Why Your Selenium Tests are so Dang Brittle, and What to Do About It
Why Your Selenium Tests are so Dang Brittle, and What to Do About ItWhy Your Selenium Tests are so Dang Brittle, and What to Do About It
Why Your Selenium Tests are so Dang Brittle, and What to Do About It
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 

Último

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Using The Page Object Pattern

  • 1. Using the Page Object Pattern to Improve Functional Test Maintainability Dante Briones Principal Consultant Electronic Ingenuity LLC http://electronicingenuity.com Friday, 07 August, 2009
  • 2. The Page Object Pattern • Technique for structuring test code that: • Promotes reuse and reduces duplication • Makes tests readable • Makes tests more robust (less brittle) • Improves maintainability, particularly if the application is rapidly evolving Friday, 07 August, 2009
  • 3. The Page Object Pattern • Demos will be coded in Java • Everything we discuss is applicable to other strongly-typed languages (e.g. C#) • Most things are applicable to dynamically- typed languages (e.g. Ruby, Python, Perl) Friday, 07 August, 2009
  • 4. Selenium IDE Quick Poll • How many using Se IDE? • How many create tests primarily through record & playback? Friday, 07 August, 2009
  • 5. Selenium IDE It’s Great Because: • It’s Free • It’s Free • Requires little or no programming experience Friday, 07 August, 2009
  • 6. Selenium IDE It falls short because: • Selenese is not a programming language • No support for loops/iteration • No support for conditionals (if...else) • No way to eliminate duplicated code! Friday, 07 August, 2009
  • 7. Selenium IDE Why is duplication bad? • Has this ever happened to you? • A tiny change to the app causes several test failures? • Let’s see an example Friday, 07 August, 2009
  • 9. Selenium IDE Why is duplication bad? • Fixing the tests will require more work than the change that caused the failure • Duplication makes code less maintainable Friday, 07 August, 2009
  • 10. Selenium IDE Summary • Great productivity for the first few tests • Maintainability decreases as the test suite grows • How can we do better? Friday, 07 August, 2009
  • 11. Start Coding Your Tests a.k.a. “Write tests in a programming language” Friday, 07 August, 2009
  • 12. Coding Your Tests Quick Poll • How many are using Selenium RC? Friday, 07 August, 2009
  • 13. Coding Your Tests How does this help? • We can eliminate duplication by building abstractions • Let’s see an example of this Friday, 07 August, 2009
  • 15. Coding Your Tests What happens next? • All commonly used methods get pulled into the base class of all tests • As the test suite grows, so does the base class • Uh oh...the base class starts getting too big Friday, 07 August, 2009
  • 16. Coding Your Tests How Big is Too Big? • You can’t tell someone else has already written the code you’re about to write • Frequent version control conflicts • Maintenance is an issue again Friday, 07 August, 2009
  • 17. Coding Your Tests How to rein in your base class? • Observation: For any given page, most of the behavior does not apply • Example: you can’t change your password on the “view cart” page • What if we moved the page-specific behavior into a corresponding class? • Voila! The Page Object is born Friday, 07 August, 2009
  • 18. The Page Object Friday, 07 August, 2009
  • 19. The Page Object What does it do? • Consolidates the code for interacting with any given UI element • Allows you to model the UI in your tests Friday, 07 August, 2009
  • 20. The Page Object What does it do? • Exposes methods that reflect the things a user can see and do on that page, e.g. • addItemToCart(), getPrice() • getEntryTitle(), saveDraft(), publishEntry() • Hides the details of telling the browser how to do those things Friday, 07 August, 2009
  • 22. The Page Object Results • Test code is very readable • No duplication of Selenium API calls • Interactive documentation via Ctrl-Space • Eminently reusable code Friday, 07 August, 2009
  • 23. The Page Object Results • This technique is framework-agnostic • Has been used with Selenium, WebDriver (Selenium 2.0), Watir, and others • I’ve even used it to drive desktop apps Friday, 07 August, 2009
  • 24. The Page Object Results • Because it encapsulates the details of the test framework API: • You can use this technique to simplify the process of swapping frameworks • In theory, you only need to reimplement the Page base class. Friday, 07 August, 2009
  • 25. But wait, there’s more! It gets better! • Page Objects improve maintainability • They also provide an opportunity to make test creation extremely quick (and maybe even fun!) • How? Page Objects + Method Chaining Friday, 07 August, 2009
  • 26. Method Chaining What’s method chaining? • Change the signature of user behavior methods so that they return the page object itself • Allows multiple behavior methods to be called in sequence Friday, 07 August, 2009
  • 27. Method Chaining What will it do for me? • Removes for “code clutter” • Tests become even more readable Friday, 07 August, 2009
  • 28. Method Chaining How does it work in practice? • All Page Object methods return a reference to a Page Object • If the “user action” moves the focus to a different page, the method should return that page object • Otherwise, return the same page object • Time for an example Friday, 07 August, 2009
  • 30. Method Chaining Results • Test code is even more readable • Very quick to write • (Actually kinda fun. Don’t tell anyone!) Friday, 07 August, 2009
  • 31. Method Chaining Caveats • Dependent on tool support • Lots of options: IntelliJ IDEA, Eclipse, NetBeans, VisualStudio Friday, 07 August, 2009
  • 32. Method Chaining Caveats • Tool support depends on language • Excellent support for strongly typed languages like Java and C# • Support is “up and coming” for dynamically typed languages (Ruby, Python, and Perl) Friday, 07 August, 2009
  • 33. The Page Object Pattern • Technique for organizing test code that: • Promotes reuse and reduces duplication • Makes tests readable • Makes tests more robust (less brittle) • Improves maintainability, particularly if the application is rapidly evolving • Is just as quick record & playback! Friday, 07 August, 2009
  • 34. Q &A Friday, 07 August, 2009