Design Patterns beyond the Page Object: An investigation into the design patterns used while building page objects.

In an age where the Page Object Pattern and Page Factory Pattern dominate web testing conversations, there is still a need to understand and apply the design patterns of yesteryear. Ideas from the Facade Pattern, Factory Method Pattern, the Iterator Pattern, the Object Pool Pattern, and the Decorator Pattern all find their way into the Page Objects we build to represent the increasingly complex widgets found on today's websites.

In this presentation, we take it back to the old school, looking at novel ways to apply classic design patterns, like those developed by the Gang of Four and Code Complete, to new screen scraping problems. We will investigate three common scenarios where using the typical approach to page objects can be inefficient or difficult, including filling in a web form, iterating over data in a list, and traversing iframes to communicate with widgets. We will explore how to improve upon the naive approach to building these page objects through the use of classic design patterns. Finally, we will formalize our findings into new patterns which can be applied to more general scenarios.

Code examples will be presented in Python and based off of my work building automation tools for hubzero.org, a platform for scientific collaboration.

 
4 favorite thumb_down thumb_up 0 comments visibility_off  Remove from Watchlist visibility  Add to Watchlist
 

Outline/structure of the Session

  1. Introduction / motivation for investigating better approaches to interacting with web forms,
    lists of items, and elements inside of iframes. (5 minutes)
  2. Filling in web forms (15 minutes)
    1. Goal of the web form - collect data from the user
    2. Typical web form page object
      • widgets for text, select, check box entries
      • submit and cancel buttons
      • repeating the same find_element/clear/send_keys commands to populate each element.
    3. Newly suggested interface
      • populate_form() method fills in the form with provided data.
      • submit_form() methods calls populate_form, clicks submit button.
      • methods accept dictionary of data used to fill in the form keys are field names, values are field values
    4. Providing a "value" method or property to page objects
    5. Different types of web forms:
      • OrderedWebForm - filling in a form where order matters
      • PreviewWebForm - web form with a preview button
    6. WebForm Pattern
      • Builds upon the Facade Pattern to create a simple interface for interacting with web forms.
      • Relies upon page objects knowing how to set the value of the web element they represent.
  3. Iterating over items in a list (15 minutes)
    1. Goal of data in a list
      • present the user with dynamically generated results, possibly from a search.
      • user can choose to interact with a single item at a time.
      • users may want to search for a particular item, requires iterating over list.
    2. Typical list page object
    3. Newly suggested interface
      • Container class
        1. represents properties of the list as a whole.
        2. provides methods for searching the list.
        3. search methods return Item objects representing a specific item.
      • Item class
        1. represents a single item in the list.
        2. item specific actions happen through this object.
        3. can be updated to point to a different item in the list
    4. Using Templatized Locators to implement ideas from Object Pool Pattern
    5. ItemList Pattern
      • Incorporates Iterator Pattern and Factory Method Pattern
      • Can be applied to any countable list of items including items in a and rows in a
  4. Interacting with elements in iframes (15 minutes)
    1. Goals of wrapping elements in iframes
      • Separation of JavaScript and CSS between contexts
      • Pulling in data from external site
      • Old way of supporting JavaScript tricks in older browsers
    2. Typical way to interact with elements in default browser context
      • search for the element
      • interact with the element
    3. Typical way to interact with elements in an iframe context
      • search for iframe
      • switch to iframe context
      • search for the element
      • interact with the element
      • exit iframe context, return to default browser
    4. Pitfalls with typical approach
      • Need to define multiple versions of widgets, one for regular use, one for iframe use.
      • What happens if the widget is embedded in multiple iframes?
    5. Newly suggested interface
      • wrap the methods of the original object with code to appropriately enter and exit the iframe context.
    6. IframeWrap Pattern
      • Uses Decorator Pattern to wrap methods and properties of a widget with calls to enter and exit the iframe context.
      • Widgets can be wrapped multiple times, allowing widgets embedded in more than one iframe.
      • Wrapped widgets maintain the same interface as if it was not embedded in an iframe.
      • Promotes reuse of widgets
  5. Summary, "Name that Pattern" game (5 minutes)
  6. Questions (5 minutes)

 

Learning Outcome

After attending this talk, participants will:

1) Understand how to simplify interactions with web forms by using the WebForm Pattern.

2) Understand how to work with lists of items by using the ItemList Pattern.

3) Understand how to deal with html elements inside of iframes by using the IframeWrap Pattern.

4) Be introduced to ideas from well established Design Patterns and how they can be incorporated into solutions for website test automation.

Target Audience

Test writers interested in alternative ways to dissect web pages. People who understand the Page Object Pattern and are wondering what comes next.

schedule Submitted 3 years ago

Comments Subscribe to Comments

comment Comment on this Proposal

  • Anand Bagmar
    Anand Bagmar
    Director - Quality
    Vuclip Inc.
    schedule 3 years ago
    Sold Out!
    45 mins
    Experience Report
    Advanced

    Page-Object pattern is very commonly used when implementing Automation frameworks. However, as the scale of the framework grows, there is a limitation on how much reusability really happens. It inherently becomes very difficult to separate the test intent from the business domain.

    I want to talk about this problem, and the solution I have been using - Business Layer - Page - Object pattern, which has helped me keep my code DRY.

  • -
    -
    ---
    -
    schedule 2 years ago
    Sold Out!
    45 mins
    Talk
    Intermediate

    As the WWW morphed from a system of interlinked hypertext documents to an advanced application delivery platform, the requirements on the underlining technologies and the browsers implementing them changed dramatically.

    To ensure correctness in behaviour and that application code works across multiple browsers, standards come equipped with test suites.  But interoperability can only be guaranteed by a more thorough testing effort.  The W3C has launched a new project called Test the Web Forward to bridge this gap, and WebDriver sits at its centrepiece.

    The talk will focus on the infrastructure that is being created to run these tests, and exemplify how the WebDriver library can be utilized in a complex and untraditional test running framework.  It will also give a glance into the ongoing W3C WebDriver specification work, and where we are headed.

  • Liked Igor Khrol
    keyboard_arrow_down

    Increase Selenium tests stability via JavaScript

    30 mins
    Talk
    Intermediate

    UI-tests are not really stable. Some sync point might be missed and tests will be red from time to time without any obvious reason. Or accidentally some focus might go away and button will not be clicked. These and other cases make automated testing results unpredictable and these results are not trusted. 

    In my speech I want to share the experience how to reach reliable and reproducible results with Selenium tests. In order to reach it we should sacrifice to 100% end user emulation. The presentation is based on the real project where this idea was successful. Also more common recommendations will be given publicity.

  • Liked dima kovalenko
    keyboard_arrow_down

    Scaling and managing Selenium Grid

    45 mins
    Talk
    Intermediate

    Managing the Selenium Grid can be very difficult, especially as you scale it up.  This session will demonstrate how we were able to scale the Selenium Grid with multiple operating systems, in multiple data centers across many continents. With the use of Selenium Grid Extras, and open source project, we were able to get much better control of individual nodes, manage WebDriver versions and much more. 

  • Liked Oren Rubin
    keyboard_arrow_down

    Page Objects Done Right

    Oren Rubin
    Oren Rubin
    Founder and CEO of Testim
    Testim.io
    schedule 3 years ago
    Sold Out!
    60 mins
    Talk
    Intermediate

    Slides: http://www.slideshare.net/orenrubin/page-objects-presentation-selenium-conference-2014-38767492

    In this talk I will walk the audience step by step at building tests using the Page Object Design Pattern, making several attempts until we reach the current recommendation. We'll see the dos, don'ts, and common pitfalls.

    In this presentation I'll also cover the Page-Factory Design Pattern, and best practices for dealing with asynchronously and how to remove the deadly "random sleeps".

  • Liked Naresh Jain
    keyboard_arrow_down

    Selenium DeTox for Achieving the Right Testing Pyramid

    Naresh Jain
    Naresh Jain
    Founder
    ConfEngine.com
    schedule 3 years ago
    Sold Out!
    45 mins
    Case Study
    Intermediate

    Our project was a classic example of Selenium gone wild! As our team embraced the test automation journey, we went crazy and implemented tons of Selenium tests, one for every permutation possible. Soon we realized our feedback cycles were delayed. Our builds were taking hours instead of minutes. And we had a set of complex, fragile tests, which resulted in a lot of false-negative scenarios and finger pointing.

    At this point, our team had realized that this is not the path forward. We decided to seriously look at our Selenium tests. We pretty much moved 80% of our Se tests to lower-layers (non-GUI based) tests. And now we have the right testing pyramid on our project.

    Join us, as we explain our journey (strategy, techniques, tools, mindset-change and approaches we took) through this transition.

  • Liked Syed Khaja Habeebuddin
    keyboard_arrow_down

    There is more treasure in Selenium nodes than in all the pirate's loot on Treasure Island.

    30 mins
    Talk
    Intermediate

    There is so much valuable data that Selenium Nodes writes into log file(s) when tests get executed on them. So much of this data is not mined for actionable intelligence.

    In this session, we will show you how operating system level metrics can be combined with data from Selenium nodes to result in rich actionable intelligence that will tremendously aid in the analysis of test failures, react to test execution flakiness, and to improve your automated test resiliency.

  • Liked Prasanna Kanagasabai
    keyboard_arrow_down

    Testing "Injection" Attacks with Selenium

    60 mins
    Demonstration
    Intermediate

    Business applications are growing at a break neck speed to cater to ever increasing business need. The dream of ever-connected systems and information at fingertips is quickly becoming a fact. This dream has brought out an evolution of online-real time applications with multiple requirements and functionalities. The down side to this security is being forced to take a back seat. Add to this the sheer quantum of code to cover is overwhelming to a manual security tester.

    One of the most common attacks against web applications is injection attack; injection flaw allows a malicious user to send malicious input to an application. The consequences of having injection flaw in your application can range from a user be able to steal all the data from your database to extreme situation like he having a command access to your infrastructure. We in this session want to show the power of automation using selenium. We will demonstrate how we are writing some interesting scripts to automate the testing of injection attacks in web applications. The outcome of automation is that we have been able get a fair code coverage and gives the time to security tester to concentrate on more tests that need his manual expertise say business logic failure or a design failure. 

    Though selenium could be used to automate far larger scope but we choose Injections as a priority for these sessions as injections form a large part of the web application attack landscape. We intend to give you some of the learning’s we had in the past, and some pitfalls we noticed. One could take the same idea and extrapolate to other attacks too.

    Attacks we plan to cover 

    1. SQL Injection 

    2. Command Injection 

    3. XSS 

  • Liked Isaac Murchie
    keyboard_arrow_down

    Selenium in the palm of your hand: Appium and automated mobile testing

    Isaac Murchie
    Isaac Murchie
    Software Developer
    Sauce Labs
    schedule 3 years ago
    Sold Out!
    45 mins
    Talk
    Intermediate

    The mobile world is growing, and it has never been easier to test applications—native, web, or hybrid—using Appium, a free, open-source implementation of the Selenium protocol for automating mobile devices. I will show how Appium, which is in active development and recently shipped version 1.0, allows developers and testers to harness all the power of the native testing frameworks provided by the mobile device manufacturers, but within the context familiar to Selenium users. 

    Further, Appium provides a very good opportunity for looking at the challenges for a technology designed to automate web browsers as it moves into a new realm. I will discuss how functionality was repurposed for this new context, as well as the ways in which the protocol was extended and made more flexible in light of the the expanded use case.

    As a case study in extended functionality, I will discuss the gesture API, which allows a standardized way to automate the sorts of advanced mutli-finger gestures used on modern mobile devices.

  • Liked Sreedevi Vedula
    keyboard_arrow_down

    WebDriver and Cucumber in the JavaScript Land!

    90 mins
    Demonstration
    Intermediate

    WebDriverJS and Cucumber.js are new entrants in the WebDriver eco-system and are gaining popularity by the day! These JavaScript ports for WebDriver and Cucumber enable us to test the JavaScript UI apps built using frameworks like Angular JS, Ember.JS with great ease.

    The UI tests can be written in JavaScript, thereby using the same technical stack of the application and the tests seamlessly integrate with the code for continuous integration and continuous delivery.

    The session is a demonstration of test framework using Cucumber.js and WebDriverJS for testing an open-source Angular JS application.

  • Liked Artem
    keyboard_arrow_down

    Allure framework - crystal clear reports for your selenium tests [in any language]

    Artem
    Artem
    Test Team Lead
    Yandex
    schedule 3 years ago
    Sold Out!
    30 mins
    Talk
    Beginner

    It's pretty cool to have selenium test results clear to everyone on the team. There are lots of frameworks in every language that aim to simplify test writing. But only few can provide sharp presentation of test execution output. Yandex team is working on Allure (https://github.com/allure-framework/allure-core/wiki) - an open-source framework designed to create crystal clear reports. Because of module structure it integrates easily with almost any testing tool, no matter which language you use. In my talk i will describe the basic principles and show how to integrate Allure reporting in your existing projects.

  • Liked Jim Evans
    keyboard_arrow_down

    Embrace and Extend: How the Selenium Project Convinced the World's Largest Closed-Source Company to Participate

    Jim Evans
    Jim Evans
    Contributor
    Selenium Project
    schedule 3 years ago
    Sold Out!
    60 mins
    Talk
    Beginner

    Microsoft. Just the name of the company alone can send some open-source software activists into fits of apoplexy. From the days when executives of the company compared open-source software to "a virus", the company has been seen as incredibly hostile to open-source software. It is surprising how much has changed over the years.

    This is the story of how the Selenium project has managed its relationship with the software company, from the initial, tentative, often contentious and borderline hostile reaching out, to today's open engagement. The story is told through the prism of the Internet Explorer Driver project, with slight digressions to the .NET bindings and other Microsoft technology stacks. The journey is funny, sometimes frustrating, but always entertaining, and there may be a surprise announcement or two.

  • Liked Prashant Badgujar
    keyboard_arrow_down

    Leveraging selenium webdriver for ExtJS web application automation

    30 mins
    Talk
    Intermediate

    ExtJS is a web development framework used for developing next generation web based UIs. In ExtJs the object Id's are dynamic in nature, the object id's are not static everytime the object is rendered in UI. The challenge is to automate UI functionality when the objects are dynamic. Extjs does not recommend assigning static html-ids to objects for web application development.

    Would like to share our experience how selenium webdriver with java has been leveraged in retrieving those dynamic Id's at run-time and perform operations on those objects. A way for test automation on an web application which is developed using ExtJS framework which generates the dynamic html-ids.

  • Liked Ashish Joshi
    keyboard_arrow_down

    Stuck with Windows Dialog? Do it using Selenium Standalone Server and Java code, (Automation of Windows dialog (File Download, File Upload) )

    20 mins
    Lightning Talk
    Intermediate

    How do you automate windows dialogs using Selenium?

    Following 3 ways are commonly used to deal with Windows Dialogs: (Download, Upload Dialogs) 

    1) Autoit : Need to have autoit framework installed (Additional tool installation require)
    2) Robot Class in java: Not reliable
    3) Java code using HttpRequest (Does not always work, requires href attribute)

    Instead of above options, I found that we can simply use Selenium Server Standalone jar to work with Dialogs using simple java code.

    For any other Advanced and complex scenarios,

    we can use .Net framework to handle the dialogs or any windows based application.I have developed a Code (using .net framework) using which we can do Automation of Windows Components e.g. calulator, Notepad.

  • Liked Justin Ison
    keyboard_arrow_down

    Using Appium and Selenium to run cross-platform (iOS, Android, Web) integration tests in parallel

    Justin Ison
    Justin Ison
    Senior Software Engineer
    Microsoft
    schedule 3 years ago
    Sold Out!
    30 mins
    Demonstration
    Intermediate

    At 6Wunderkinder, the maker of the Wunderlist app, we have customers whom use our app on many different platforms. It's imperative that our client apps each work perfectly together, and with our server in complete harmony. When unit and functional tests aren't enough, full end-to-end integration tests are needed so we've harnessed the awesome power of Selenium and Appium to accomplish this.

  • 20 mins
    Talk
    Beginner

    Internationalization(I18N), Localization(L10N) testing helps to ensure the application is instinctive, explicable and correct for the people who are accessing from different geographical locations and from various languages.

    We are prenting the session on How selenium helps in Portal content verification, live language translation during chat and mobile language translation.

  • 60 mins
    Demonstration
    Intermediate

    In Agile teams, as developers are able to deliver new features even faster, Testers also need to find a way to implement test scripts quicker. Design Patterns can help with that, as they provide a reusable solution to commonly occuring problems. In this session, we would demonstrate the advantages of using patterns and how we can apply Page object model and Factory patterns to speed-up test script creation.

  • Liked Ivan Shubin
    keyboard_arrow_down

    Automated testing for responsive design on multi-screen devices using Galen Framework

    60 mins
    Demonstration
    Intermediate

    iPhone 3g, iPhone 4s, iPhone 5s, Samsung Galaxy, Samsung Galaxy Note, IE, Chrome, Firefox etc... Can you automate layout testing for these with one test?
    At eBay we had to refine our strategy for responsive design implementation. As part of that we wanted to build a stable automated test set that would cover layout testing on multiple screen resolutions. Now whenever there is a small change to a CSS that breaks the design on some specific resolutions - we notice it right away. Do you also have to test your website on different devices? Would you like to automate that and save time? It's easy as 1, 2, 3: write your Selenium test (with a bit of magic of Galen), include it in your continuous integration environment (e.g. Jenkins), get feedback with detailed reports.
    In this presentation we would like to show you how to build a stable solution for testing responsive layout with an open sourced tool Galen Framework. We'll introduce you to Test Driven Development for Responsive Design. We'll show you how to execute tests in Selenium Grid to cover the browser compatibility testing and how we adapted the responsive layout testing at eBay.

  • Liked Santiago S Ordoñez
    keyboard_arrow_down

    Enter JS Unit testing: Cross Browser, reliable, fast and developer friendly

    45 mins
    Talk
    Intermediate

    Ever been frustrated by slow, unreliable Selenium tests that won't work in all browsers? Chances are you're doing it wrong.

    Selenium is an excellent tool, but as all tools, should only be used for the right purpose.

    In this talk I want to walk the audience through current approaches, frameworks, tools and the advantages or using Javascript Unit Tests to get extensive client-side coverage, reliable and millisecond-speed results.

    Leverage client-side unit testing as a complement to a more focussed and stable set of functional Selenium tests. Use the power of Sauce Labs' Javascript API to run these across all browsers with very little effort.

     

     

  • Liked Amit Rawat
    keyboard_arrow_down

    Testing of Responsive Web Applications using Appium and WebDriver API

    60 mins
    Tutorial
    Intermediate

    All the modern web applications uses HTML5 and RWD (Responsive Web Design) to have an optimal viewing experience across a wide range of devices (from mobile phones to desktop computer monitors). Automating these applications and running the scripts on different devices is a bigger challenge.

    How Appium and Selenium WebDriver API can be used to automate these applications and can also address all the challenges like:

    1. Running the Webdriver scripts on iOS Safari and Android Chrome with minimal changes to the scripts.

    2. Working with the Responsive web elements and validating their size and layout on different devices and viewports.

    3. Automating complex gestures like Swipe, Tap, Pull to refresh etc.

    4. Working with HTML5 based geo-locations and simulating the Mobile network bandwidth and latency using Browsermob