SlideShare a Scribd company logo
Beyond Page Objects
                                    Dante Briones
                                    SeleniumConf
                                     5 April 2011

                             http://electronicingenuity.com
                            dante@electronicingenuity.com
                                     @dantebriones

Wednesday, 06 April, 2011
Let’s Start With A Story




Wednesday, 06 April, 2011
A long time ago* in an investment bank
                                     far, far away...




                                       *(2005)

Wednesday, 06 April, 2011
Our Hero




Wednesday, 06 April, 2011
A Chance Encounter




Wednesday, 06 April, 2011
A New Weapon




Wednesday, 06 April, 2011
Engaging The Enemy




Wednesday, 06 April, 2011
Victory


                                  MUCH more readable!




Wednesday, 06 April, 2011
What’s The Moral?


                        (hint: it’s not about the developer, the
                        author, or the book)




Wednesday, 06 April, 2011
The Details




Wednesday, 06 April, 2011
Why Page Objects?




Wednesday, 06 April, 2011
Why Page Objects?




Wednesday, 06 April, 2011
Why Page Objects?




Wednesday, 06 April, 2011
Tests Are Code


                             They need TLC



Wednesday, 06 April, 2011
Readability


        selenium.click(“id=itemAction1138”);
        assertEquals(“1”, selenium.getText(“css=#cart .count”));

                                   vs.
        item.clickAddToCart();
        assertEquals(1, cart.getItemCount());




Wednesday, 06 April, 2011
Stay DRY
         Test class:
         selenium.click(“id=zoom_out_action”);
         selenium.click(“id=zoom_out_action”);

                                     vs.
         Test class:
         map.zoomOut();
         map.zoomOut();
         Map class:
         selenium.click(“id=zoom_out_action”);


Wednesday, 06 April, 2011
Robustitude


         Thread.sleep(250); //wait for button to appear
         selenium.click(“id=a_button”);
         Thread.sleep(500); //wait for results to show up
         assertEquals(selenium.getText(“id=results”),
             “False Negatives suck!”);




Wednesday, 06 April, 2011
Sensible Names

                    • catalogItem.addToCart()
                    • blogEntry.post()
                    • auction.bid(25.00)


Wednesday, 06 April, 2011
Small Classes




Wednesday, 06 April, 2011
How Do We Get
                               There?

                    • Refactoring
                    • Apply Design Patterns
                    • Continuous Improvement


Wednesday, 06 April, 2011
How Do We Get
                               There?




Wednesday, 06 April, 2011
Context

                    • Several consulting gigs over the past few
                            years
                    • Current client:
                     • consumer-facing RIA
                     • tests written with Selenium 1 API in Java

Wednesday, 06 April, 2011
PRO TIP


                            Use WebDriver


Wednesday, 06 April, 2011
Page Objects Recap

                    • Model the application’s UI
                    • Expose methods that reflect the things a
                            user can see and do on that page
                    • Hides the details of telling the browser
                            how to do those things



Wednesday, 06 April, 2011
Page Object Benefits

                    • Readable tests
                    • Reduced or eliminated duplication
                    • Self-verification
                    • Reusability

Wednesday, 06 April, 2011
So Why Go “Beyond”?


                            Web Apps Are Different Now




Wednesday, 06 April, 2011
Why Go “Beyond”?


                                   meh

                                  OMG SOOO MUCH BETTER




Wednesday, 06 April, 2011
Why Go “Beyond”?




Wednesday, 06 April, 2011
Why Go “Beyond”?


                             Because modern web apps are
                                 dynamic and rich




Wednesday, 06 April, 2011
Example: Pivotal Tracker




Wednesday, 06 April, 2011
Wednesday, 06 April, 2011
Modeling The UI
         public class IssueSummary {
                   public IssueDetail expand() {...}
         }


         public class IssueDetail {
                   public void save() {...}
                   public void cancel() {...}
                   public String getStoryId() {...}
         }




Wednesday, 06 April, 2011
What’s This, Then?


                 I call them “Page Components”



Wednesday, 06 April, 2011
Method Chaining: Focus
                      Stays Put
         public class IssueDetail {
                   public void save() {...}
                   public IssueDetail addComment(String comment) {
                      ...
                      return this;
                  }
         }


         issueDetail.addComment().save();




Wednesday, 06 April, 2011
Method Chaining: Focus
                  Moves Elsewhere
         public class IssueDetail {
                  public ConfirmationDialog delete() {
                      ...
                      return new ConfirmationDialog();
                  }
         }


         issueDetail.delete().confirm();
         or
         issueDetail.delete().cancel();



Wednesday, 06 April, 2011
Page Component
                                   Recap

                    • Just like Page Objects... but littler
                    • Use return types to model the user
                            experience




Wednesday, 06 April, 2011
ComponentFactory


                              Do you like to type? I don’t.




Wednesday, 06 April, 2011
ComponentFactory


                                              1/(keystrokes
                        Job Satisfaction =   required write
                                             useful code)




Wednesday, 06 April, 2011
ComponentFactory
         public class ComponentFactory {
               public IssueSummary issueSummary() {
                            return new IssueSummary(...);
               }
         }
         public abstract BaseTestCase {
               protected ComponentFactory withComponent() {
                            return new ComponentFactory();
               }
         }



Wednesday, 06 April, 2011
ComponentFactory

                               new IssueSummary(selenium).expand();



                                               vs.
                             withComponent().issueSummary().expand();




Wednesday, 06 April, 2011
ComponentFactory
                                Recap

                    • Interactive documentation
                    • Easier entry point into component creation
                    • Another way to use strong typing to make
                            the tests easier to write




Wednesday, 06 April, 2011
Indexed Components




Wednesday, 06 April, 2011
Indexed Components


         IssueSummary summary =
               withComponent().backlog().issueSummary(0);
         assertEquals(summary.getTitle(), “some title”);




Wednesday, 06 April, 2011
Indexed Components

         CSS locators:
         Backlog = #backlog
         First issue summary = #backlog .issue-summary:nth(0)
         “Expand” button = #backlog .issue-summary:nth(0) .expand
         Title = #backlog .issue-summary:nth(0) .title




Wednesday, 06 April, 2011
The Locator Class
         public class Locator {
             protected int index;

                   public Locator(String rootLocator, int index) {
                     this.rootLocator = rootLocator;
                     this.index = index;
               }

                   public String of(String containedElement) {
                       return String.format(rootLocator, index) +
                             " " + containedElement;
                   }
         }


Wednesday, 06 April, 2011
Using A Locator
         public IssueDetail expand() {
               selenium.click(“#backlog .issue-summary:nth(0) .expand”);
               ...
       }

                                         vs.

       public IssueDetail expand() {
               selenium.expand(locator.of(“.expand”));
               ...
       }

Wednesday, 06 April, 2011
Synchronization Issues

                       Two kinds:
                       1. Element not present yet
                       2. Element content not updated yet




Wednesday, 06 April, 2011
Thread.sleep()


                                        NO.*
                            STEP AWAY FROM THE KEYBOARD.




Wednesday, 06 April, 2011
Thread.sleep()


                                            NO.*
                            STEP AWAY FROM THE KEYBOARD.


                             (*unless you have no other choice)


Wednesday, 06 April, 2011
Thread.sleep()

       Just be sure to wrap it in an appropriately named method:




Wednesday, 06 April, 2011
Thread.sleep()

       Just be sure to wrap it in an appropriately named method:

 • sleepAsALastResortWhenNothingElseWorks()




Wednesday, 06 April, 2011
Thread.sleep()

       Just be sure to wrap it in an appropriately named method:

 • sleepAsALastResortWhenNothingElseWorks()
 • sleepToMakeThisTestMoreFlakyThusEnsuringMyJobSecurity()




Wednesday, 06 April, 2011
Thread.sleep()

       Just be sure to wrap it in an appropriately named method:

 • sleepAsALastResortWhenNothingElseWorks()
 • sleepToMakeThisTestMoreFlakyThusEnsuringMyJobSecurity()
 • sleepBecauseImTooLazyToSolveThisProperly()




Wednesday, 06 April, 2011
Use The Wait Class


                        ...to delay the test until the app exhibits
                        certain behavior rather than waiting for an
                        arbitrary amount of time.




Wednesday, 06 April, 2011
Two Options

                    1. Subclass DefaultSelenium and override the
                       click() method
                    2. Extract a BaseComponent class that
                       provides a click() method for use by all
                       subclasses




Wednesday, 06 April, 2011
Next Issue


                        The element is present in the DOM, but
                        doesn't contain the right data yet.




Wednesday, 06 April, 2011
Cleanest Solution


                             Build the app for testability




Wednesday, 06 April, 2011
Next Best Solution

         public IssueDetail addComment() {
               int initialCount = getCommentCount();
               selenium.type(locator.of(“.comment-entry”));
               selenium.click(locator.of(“.add-comment”));
               waitUntilCommentCountIs(initialCount + 1);
               return this;
       }




Wednesday, 06 April, 2011
Final Thoughts


                              Beyond “Beyond”?




Wednesday, 06 April, 2011
Thank You!


                             http://electronicingenuity.com
                            dante@electronicingenuity.com
                                     @dantebriones




Wednesday, 06 April, 2011
References

                    •       Dan North on Best Practices:

                            •   http://www.viddler.com/explore/kvarnhammar/videos/6/

                    •       Adam Goucher on built-in test synchronization:

                            •   http://saucelabs.com/blog/index.php/2011/02/advanced-selenium-
                                synchronization-with-latches/




Wednesday, 06 April, 2011

More Related Content

Viewers also liked

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
Sargis Sargsyan
 
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
SQALab
 
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
Alan Richardson
 
BDD Anti-patterns
BDD Anti-patternsBDD Anti-patterns
BDD Anti-patterns
John Ferguson Smart Limited
 
Perils of Page-Object Pattern
Perils of Page-Object PatternPerils of Page-Object Pattern
Perils of Page-Object Pattern
Anand Bagmar
 
Specifications For Enterprise Testing
Specifications For Enterprise TestingSpecifications For Enterprise Testing
Specifications For Enterprise Testing
Sathyan Sethumadhavan
 
Specification by Example
Specification by ExampleSpecification by Example
Specification by Example
Sergey Shishkin
 
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
 
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
 
Сергей Татаринцев — Тестирование CSS-регрессий с Gemini
Сергей Татаринцев — Тестирование CSS-регрессий с GeminiСергей Татаринцев — Тестирование CSS-регрессий с Gemini
Сергей Татаринцев — Тестирование CSS-регрессий с Gemini
Yandex
 
Page object with selenide
Page object with selenidePage object with selenide
Page object with selenide
COMAQA.BY
 
CukeUp 2016 Agile Product Planning Workshop
CukeUp 2016 Agile Product Planning WorkshopCukeUp 2016 Agile Product Planning Workshop
CukeUp 2016 Agile Product Planning Workshop
John Ferguson Smart Limited
 
Hybrid automation framework
Hybrid automation frameworkHybrid automation framework
Hybrid automation framework
doai tran
 
Serenity-BDD training
Serenity-BDD trainingSerenity-BDD training
Serenity-BDD training
Savvycom Savvycom
 
Estimation techniques and software metrics
Estimation techniques and software metricsEstimation techniques and software metrics
Estimation techniques and software metrics
Mae Abigail Banquil
 
Out of box page object design pattern, java
Out of box page object design pattern, javaOut of box page object design pattern, java
Out of box page object design pattern, java
COMAQA.BY
 
Design patterns in web testing automation with WebDriver
Design patterns in web testing automation with WebDriverDesign patterns in web testing automation with WebDriver
Design patterns in web testing automation with WebDriver
Mikalai Alimenkou
 
Hybrid framework for test automation
Hybrid framework for test automationHybrid framework for test automation
Hybrid framework for test automationsrivinayak
 
Moving Towards Zero Defects with Specification by Example
Moving Towards Zero Defects with Specification by ExampleMoving Towards Zero Defects with Specification by Example
Moving Towards Zero Defects with Specification by Example
Steve Rogalsky
 

Viewers also liked (20)

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
 
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
 
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
 
BDD Anti-patterns
BDD Anti-patternsBDD Anti-patterns
BDD Anti-patterns
 
Perils of Page-Object Pattern
Perils of Page-Object PatternPerils of Page-Object Pattern
Perils of Page-Object Pattern
 
Specifications For Enterprise Testing
Specifications For Enterprise TestingSpecifications For Enterprise Testing
Specifications For Enterprise Testing
 
Specification by Example
Specification by ExampleSpecification by Example
Specification by Example
 
Refactoring page objects The Screenplay Pattern
Refactoring page objects   The Screenplay Pattern Refactoring page objects   The Screenplay Pattern
Refactoring page objects The Screenplay Pattern
 
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...
 
Сергей Татаринцев — Тестирование CSS-регрессий с Gemini
Сергей Татаринцев — Тестирование CSS-регрессий с GeminiСергей Татаринцев — Тестирование CSS-регрессий с Gemini
Сергей Татаринцев — Тестирование CSS-регрессий с Gemini
 
Page object with selenide
Page object with selenidePage object with selenide
Page object with selenide
 
CukeUp 2016 Agile Product Planning Workshop
CukeUp 2016 Agile Product Planning WorkshopCukeUp 2016 Agile Product Planning Workshop
CukeUp 2016 Agile Product Planning Workshop
 
Hybrid automation framework
Hybrid automation frameworkHybrid automation framework
Hybrid automation framework
 
Serenity-BDD training
Serenity-BDD trainingSerenity-BDD training
Serenity-BDD training
 
Estimation techniques and software metrics
Estimation techniques and software metricsEstimation techniques and software metrics
Estimation techniques and software metrics
 
Out of box page object design pattern, java
Out of box page object design pattern, javaOut of box page object design pattern, java
Out of box page object design pattern, java
 
Design patterns in web testing automation with WebDriver
Design patterns in web testing automation with WebDriverDesign patterns in web testing automation with WebDriver
Design patterns in web testing automation with WebDriver
 
Hybrid framework for test automation
Hybrid framework for test automationHybrid framework for test automation
Hybrid framework for test automation
 
Moving Towards Zero Defects with Specification by Example
Moving Towards Zero Defects with Specification by ExampleMoving Towards Zero Defects with Specification by Example
Moving Towards Zero Defects with Specification by Example
 
Hybrid framework
Hybrid frameworkHybrid framework
Hybrid framework
 

Similar to Beyond Page Objects

Using+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsUsing+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsMuhammad Ikram Ul Haq
 
What's Cooking in Xtext 2.0
What's Cooking in Xtext 2.0What's Cooking in Xtext 2.0
What's Cooking in Xtext 2.0
Dr. Jan Köhnlein
 
Node js techtalksto
Node js techtalkstoNode js techtalksto
Node js techtalksto
Jason Diller
 
Namesmatter
NamesmatterNamesmatter
Namesmatter
Adam Goucher
 
HTML5 and jQuery for Flex Developers
HTML5 and jQuery for Flex DevelopersHTML5 and jQuery for Flex Developers
HTML5 and jQuery for Flex Developers
Ryan Stewart
 
Javascript Unit Testting (PHPBenelux 2011-05-04)
Javascript Unit Testting (PHPBenelux 2011-05-04)Javascript Unit Testting (PHPBenelux 2011-05-04)
Javascript Unit Testting (PHPBenelux 2011-05-04)
Tom Van Herreweghe
 
Atlassian RoadTrip 2011 Slide Deck
Atlassian RoadTrip 2011 Slide DeckAtlassian RoadTrip 2011 Slide Deck
Atlassian RoadTrip 2011 Slide Deck
Atlassian
 
Koss, How to make desktop caliber browser apps
Koss, How to make desktop caliber browser appsKoss, How to make desktop caliber browser apps
Koss, How to make desktop caliber browser appsEvil Martians
 
Javascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJSJavascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJS
Sylvain Zimmer
 
You're doing it wrong
You're doing it wrongYou're doing it wrong
You're doing it wrong
Adam Goucher
 
Milkyway@home rcos presentation_4_8_2011
Milkyway@home rcos presentation_4_8_2011Milkyway@home rcos presentation_4_8_2011
Milkyway@home rcos presentation_4_8_2011mskmoorthy
 
Notebook
NotebookNotebook
Notebook
mskmoorthy
 
Future-proofing Your JavaScript Apps (Compact edition)
Future-proofing Your JavaScript Apps (Compact edition)Future-proofing Your JavaScript Apps (Compact edition)
Future-proofing Your JavaScript Apps (Compact edition)
Addy Osmani
 
High quality iOS development
High quality iOS developmentHigh quality iOS development
High quality iOS development
Robin Lu
 
Discussing Java's Future
Discussing Java's FutureDiscussing Java's Future
Discussing Java's Future
Ray Gauss
 
Accessibility Lightning Talk
Accessibility Lightning TalkAccessibility Lightning Talk
Accessibility Lightning Talk
Russell Heimlich
 
Desacoplando aplicaciones
Desacoplando aplicacionesDesacoplando aplicaciones
Desacoplando aplicaciones
Alvaro Videla
 
A new world with cdi en
A new world with cdi enA new world with cdi en
A new world with cdi en
José Rodolfo Freitas
 
YOU WILL REGRET THIS
YOU WILL REGRET THISYOU WILL REGRET THIS
YOU WILL REGRET THIS
MononcQc
 

Similar to Beyond Page Objects (20)

Using+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsUsing+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applications
 
What's Cooking in Xtext 2.0
What's Cooking in Xtext 2.0What's Cooking in Xtext 2.0
What's Cooking in Xtext 2.0
 
Node js techtalksto
Node js techtalkstoNode js techtalksto
Node js techtalksto
 
Namesmatter
NamesmatterNamesmatter
Namesmatter
 
HTML5 and jQuery for Flex Developers
HTML5 and jQuery for Flex DevelopersHTML5 and jQuery for Flex Developers
HTML5 and jQuery for Flex Developers
 
Javascript Unit Testting (PHPBenelux 2011-05-04)
Javascript Unit Testting (PHPBenelux 2011-05-04)Javascript Unit Testting (PHPBenelux 2011-05-04)
Javascript Unit Testting (PHPBenelux 2011-05-04)
 
Atlassian RoadTrip 2011 Slide Deck
Atlassian RoadTrip 2011 Slide DeckAtlassian RoadTrip 2011 Slide Deck
Atlassian RoadTrip 2011 Slide Deck
 
Koss, How to make desktop caliber browser apps
Koss, How to make desktop caliber browser appsKoss, How to make desktop caliber browser apps
Koss, How to make desktop caliber browser apps
 
Javascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJSJavascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJS
 
You're doing it wrong
You're doing it wrongYou're doing it wrong
You're doing it wrong
 
Milkyway@home rcos presentation_4_8_2011
Milkyway@home rcos presentation_4_8_2011Milkyway@home rcos presentation_4_8_2011
Milkyway@home rcos presentation_4_8_2011
 
Notebook
NotebookNotebook
Notebook
 
Future-proofing Your JavaScript Apps (Compact edition)
Future-proofing Your JavaScript Apps (Compact edition)Future-proofing Your JavaScript Apps (Compact edition)
Future-proofing Your JavaScript Apps (Compact edition)
 
High quality iOS development
High quality iOS developmentHigh quality iOS development
High quality iOS development
 
Discussing Java's Future
Discussing Java's FutureDiscussing Java's Future
Discussing Java's Future
 
Himanshu pbe
Himanshu pbeHimanshu pbe
Himanshu pbe
 
Accessibility Lightning Talk
Accessibility Lightning TalkAccessibility Lightning Talk
Accessibility Lightning Talk
 
Desacoplando aplicaciones
Desacoplando aplicacionesDesacoplando aplicaciones
Desacoplando aplicaciones
 
A new world with cdi en
A new world with cdi enA new world with cdi en
A new world with cdi en
 
YOU WILL REGRET THIS
YOU WILL REGRET THISYOU WILL REGRET THIS
YOU WILL REGRET THIS
 

Recently uploaded

Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Globus
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 

Recently uploaded (20)

Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 

Beyond Page Objects

  • 1. Beyond Page Objects Dante Briones SeleniumConf 5 April 2011 http://electronicingenuity.com dante@electronicingenuity.com @dantebriones Wednesday, 06 April, 2011
  • 2. Let’s Start With A Story Wednesday, 06 April, 2011
  • 3. A long time ago* in an investment bank far, far away... *(2005) Wednesday, 06 April, 2011
  • 6. A New Weapon Wednesday, 06 April, 2011
  • 8. Victory MUCH more readable! Wednesday, 06 April, 2011
  • 9. What’s The Moral? (hint: it’s not about the developer, the author, or the book) Wednesday, 06 April, 2011
  • 14. Tests Are Code They need TLC Wednesday, 06 April, 2011
  • 15. Readability selenium.click(“id=itemAction1138”); assertEquals(“1”, selenium.getText(“css=#cart .count”)); vs. item.clickAddToCart(); assertEquals(1, cart.getItemCount()); Wednesday, 06 April, 2011
  • 16. Stay DRY Test class: selenium.click(“id=zoom_out_action”); selenium.click(“id=zoom_out_action”); vs. Test class: map.zoomOut(); map.zoomOut(); Map class: selenium.click(“id=zoom_out_action”); Wednesday, 06 April, 2011
  • 17. Robustitude Thread.sleep(250); //wait for button to appear selenium.click(“id=a_button”); Thread.sleep(500); //wait for results to show up assertEquals(selenium.getText(“id=results”), “False Negatives suck!”); Wednesday, 06 April, 2011
  • 18. Sensible Names • catalogItem.addToCart() • blogEntry.post() • auction.bid(25.00) Wednesday, 06 April, 2011
  • 20. How Do We Get There? • Refactoring • Apply Design Patterns • Continuous Improvement Wednesday, 06 April, 2011
  • 21. How Do We Get There? Wednesday, 06 April, 2011
  • 22. Context • Several consulting gigs over the past few years • Current client: • consumer-facing RIA • tests written with Selenium 1 API in Java Wednesday, 06 April, 2011
  • 23. PRO TIP Use WebDriver Wednesday, 06 April, 2011
  • 24. Page Objects Recap • Model the application’s UI • Expose methods that reflect the things a user can see and do on that page • Hides the details of telling the browser how to do those things Wednesday, 06 April, 2011
  • 25. Page Object Benefits • Readable tests • Reduced or eliminated duplication • Self-verification • Reusability Wednesday, 06 April, 2011
  • 26. So Why Go “Beyond”? Web Apps Are Different Now Wednesday, 06 April, 2011
  • 27. Why Go “Beyond”? meh OMG SOOO MUCH BETTER Wednesday, 06 April, 2011
  • 29. Why Go “Beyond”? Because modern web apps are dynamic and rich Wednesday, 06 April, 2011
  • 32. Modeling The UI public class IssueSummary { public IssueDetail expand() {...} } public class IssueDetail { public void save() {...} public void cancel() {...} public String getStoryId() {...} } Wednesday, 06 April, 2011
  • 33. What’s This, Then? I call them “Page Components” Wednesday, 06 April, 2011
  • 34. Method Chaining: Focus Stays Put public class IssueDetail { public void save() {...} public IssueDetail addComment(String comment) { ... return this; } } issueDetail.addComment().save(); Wednesday, 06 April, 2011
  • 35. Method Chaining: Focus Moves Elsewhere public class IssueDetail { public ConfirmationDialog delete() { ... return new ConfirmationDialog(); } } issueDetail.delete().confirm(); or issueDetail.delete().cancel(); Wednesday, 06 April, 2011
  • 36. Page Component Recap • Just like Page Objects... but littler • Use return types to model the user experience Wednesday, 06 April, 2011
  • 37. ComponentFactory Do you like to type? I don’t. Wednesday, 06 April, 2011
  • 38. ComponentFactory 1/(keystrokes Job Satisfaction = required write useful code) Wednesday, 06 April, 2011
  • 39. ComponentFactory public class ComponentFactory { public IssueSummary issueSummary() { return new IssueSummary(...); } } public abstract BaseTestCase { protected ComponentFactory withComponent() { return new ComponentFactory(); } } Wednesday, 06 April, 2011
  • 40. ComponentFactory new IssueSummary(selenium).expand(); vs. withComponent().issueSummary().expand(); Wednesday, 06 April, 2011
  • 41. ComponentFactory Recap • Interactive documentation • Easier entry point into component creation • Another way to use strong typing to make the tests easier to write Wednesday, 06 April, 2011
  • 43. Indexed Components IssueSummary summary = withComponent().backlog().issueSummary(0); assertEquals(summary.getTitle(), “some title”); Wednesday, 06 April, 2011
  • 44. Indexed Components CSS locators: Backlog = #backlog First issue summary = #backlog .issue-summary:nth(0) “Expand” button = #backlog .issue-summary:nth(0) .expand Title = #backlog .issue-summary:nth(0) .title Wednesday, 06 April, 2011
  • 45. The Locator Class public class Locator { protected int index; public Locator(String rootLocator, int index) { this.rootLocator = rootLocator; this.index = index; } public String of(String containedElement) { return String.format(rootLocator, index) + " " + containedElement; } } Wednesday, 06 April, 2011
  • 46. Using A Locator public IssueDetail expand() { selenium.click(“#backlog .issue-summary:nth(0) .expand”); ... } vs. public IssueDetail expand() { selenium.expand(locator.of(“.expand”)); ... } Wednesday, 06 April, 2011
  • 47. Synchronization Issues Two kinds: 1. Element not present yet 2. Element content not updated yet Wednesday, 06 April, 2011
  • 48. Thread.sleep() NO.* STEP AWAY FROM THE KEYBOARD. Wednesday, 06 April, 2011
  • 49. Thread.sleep() NO.* STEP AWAY FROM THE KEYBOARD. (*unless you have no other choice) Wednesday, 06 April, 2011
  • 50. Thread.sleep() Just be sure to wrap it in an appropriately named method: Wednesday, 06 April, 2011
  • 51. Thread.sleep() Just be sure to wrap it in an appropriately named method: • sleepAsALastResortWhenNothingElseWorks() Wednesday, 06 April, 2011
  • 52. Thread.sleep() Just be sure to wrap it in an appropriately named method: • sleepAsALastResortWhenNothingElseWorks() • sleepToMakeThisTestMoreFlakyThusEnsuringMyJobSecurity() Wednesday, 06 April, 2011
  • 53. Thread.sleep() Just be sure to wrap it in an appropriately named method: • sleepAsALastResortWhenNothingElseWorks() • sleepToMakeThisTestMoreFlakyThusEnsuringMyJobSecurity() • sleepBecauseImTooLazyToSolveThisProperly() Wednesday, 06 April, 2011
  • 54. Use The Wait Class ...to delay the test until the app exhibits certain behavior rather than waiting for an arbitrary amount of time. Wednesday, 06 April, 2011
  • 55. Two Options 1. Subclass DefaultSelenium and override the click() method 2. Extract a BaseComponent class that provides a click() method for use by all subclasses Wednesday, 06 April, 2011
  • 56. Next Issue The element is present in the DOM, but doesn't contain the right data yet. Wednesday, 06 April, 2011
  • 57. Cleanest Solution Build the app for testability Wednesday, 06 April, 2011
  • 58. Next Best Solution public IssueDetail addComment() { int initialCount = getCommentCount(); selenium.type(locator.of(“.comment-entry”)); selenium.click(locator.of(“.add-comment”)); waitUntilCommentCountIs(initialCount + 1); return this; } Wednesday, 06 April, 2011
  • 59. Final Thoughts Beyond “Beyond”? Wednesday, 06 April, 2011
  • 60. Thank You! http://electronicingenuity.com dante@electronicingenuity.com @dantebriones Wednesday, 06 April, 2011
  • 61. References • Dan North on Best Practices: • http://www.viddler.com/explore/kvarnhammar/videos/6/ • Adam Goucher on built-in test synchronization: • http://saucelabs.com/blog/index.php/2011/02/advanced-selenium- synchronization-with-latches/ Wednesday, 06 April, 2011