Selenium WebDriver Page Object Abstractions and Beyond

I’ve been collating my thoughts on Page Objects and Abstraction Layers, particularly the implementation of them using Java.

I presented my initial thoughts at Let’s Test 2014 in a half day workshop. This could easily have been a full day workshop to allow for more experimentation with the different coding styles.

I released the slides to the tutorial on slideshare.

I confess to some nervousness about releasing the information since I don’t normally release the slides to tutorials and courses in case it cuts down on the value of running the tutorial or course again.

But, in this case, I don’t see enough information on the web about multiple Abstraction Layers and different ways of doing Page Objects, so I thought I’d throw my work out there, along with the supporting source code.

I’m presenting this material as a ‘talk’ rather than a workshop at StarWest 2014, and at Oredev 2014.

On a related note. I fronted a discussion at the Test Management Summit 2014 on Automation Abstractions. The slides for which were taken from the above presentation.

The aim for the slides and presentation is to demonstrate multiple approaches, so that people don’t just pick up the first ‘framework’ they see, or build ‘Page Objects’ without thinking through the modelling approaches open to them.

In the code and presentation I have examples of:

  • Page Objects
  • Page Objects that synchronize as slow loadable components
  • Navigation separate from Page Objects
  • Domain Objects
  • DOM WebElement abstractions
  • and more…

The code and slides demonstrate some of my biases.

The main point is that ‘none of these approaches are best’, and we make decisions when we build our automation. We should take responsibility for those decisions and experiment with what works best in our environment, with our coding skills, with our development standards, for our application.

I’ll expand this material in the future. But I hope it helps somewhat in its current form.

You might also find the slides for my BDD tutorial relevant since I discuss some of my thoughts on BDD and Domain Specific Languages as Abstraction Layers.

This entry was posted in Conferences, Practices, Selenium Simplified Blog. Bookmark the permalink.

4 Responses to Selenium WebDriver Page Object Abstractions and Beyond

  1. Tim Western says:

    I just found this, so I’m not sure when it was published (its not clear cause your blog doesn’t have a published date). However, I really like some of the ideas you’ve presented. I’ve spent much of the last three years, slowly arriving at some similar ideas relating to Selenium, and wish I could have seen one of your tutorials at one of the above conferences (but alas no budget this year for travel).

    Two things that jumped out at me. I don’t recall what I called them on the last project I did automation, but a lot of my data I used as hashes, which in ruby were very light weight. In .net I definitely had Domain objects to use for data, and TestDataBuilders to compose the data, so it was more fluent.

    You talk a lot about abstraction, and I agree, you need multiple layers of it. Ideally, I’d want no more than three statements in any test method. 1 to setup the data for that test (if it wasn’t done in a Setup method), 1 to perform all the operations to get to the Assert point, and then the Assert. Of course sometimes, you need more than that, but I’ve seen a lot of tests that are so messy its hard to tell what is really going on. So I tend, personally to favor, having the page objects generally, only return page objects, and to limit operations done within the page objects, to convenience methods that may get reused like say FillForm(FormData). I then would have an intermediary class that would perform most all of the operations, and act as an ‘interface’ between the page object itself, and whatever is calling it. Call them Driver methods, or Page Operation Classes. The risk here is that you might feel some coupling between the two, but I want the responsibility of the Page Objects to primarily be to get the element I want to work with. As soon as you put an add there, (even the fill form idea may be going to far), you likely have violated the SRP. SO I definitely feel a need to do that, and you might need additional support classes for other things. Data Setup is a good example, of what you might want.

    I would love to hear more sometime.

  2. Pingback: Testing Bits – 9/7/14 – 9/13/14 | Testing Curator Blog

  3. Pingback: Question: What is the best Page Object framework for Java? » Selenium Simplified

Leave a Reply

Your email address will not be published. Required fields are marked *