The future of PageObject

This post is going to layout the direction I am taking the PageObject gem. But first, a little history is in order.

When I first created the PageObject gem there was a significant difference between the Watir and Selenium gems. The PageObject gem started as a high-level wrapper around over these two gems. Over the years the difference between those gems have become distinct and now Watir is a very nice layer over Selenium.

Because of this I have decided to fundamentally change the PageObject gem. With todays’ release (2.1) I have removed the selenium platform. You can still pass a Selenium driver to the gem but it will simply be wrapped by Watir. On the API level, you will not see any differences but you might have to make some simple changes to your calls to RSpec matchers if you used the predicate matchers.

So what is different?

In addition to providing all of the high-level capabilities that have always existed in PageObject, version 2.1 is an abstraction over Watir only. One significant difference is that the gem is no longer using delegation. Delegation caused me to have to add new methods to PageObject every time Watir added a new capability. This meant that at times there was capability that existed in Watir that was not available in PageObject. With this release the gem will forward method invocations to the watir natives without displaying the deprecation warning. This means that as soon as something new is added to Watir it is immediately available to PageObject.

Will I need to change any code?

You might have to make a change to some of your expectations. If you use the RSpec predicate matchers then you should be aware that it will check to see if the method is available before calling it and if it doesn’t exist it will throw an error. So if you have had code like this:

expect(my_element).to be_visible

then RSpec will check to see if the visible? method exists. In the new version of PageObject it doesn’t exist. This call is intercepted and sent to Watir. This means you will get an error. You can simply change the exception to this:

expect(my_element.visible?).to be(true), 
        "expected my_element to be visible"

and everything should be fine. Notice that I provided the additional parameter to make the message meaningful in the case of a failure.

So what is the path forward?

Version 2.2 will be released in a week or two and it will remove the way that the gem is injecting the Watir platform and further simplify the code. A week or two after that I will release 2.3 which will remove the final pieces of this larger refactoring – the parts that build out custom path.

From that point further the gem will continue to focus on providing high-level functionality that will make testing easier. I will also be focusing on addressing other issues we run into when writing tests – namely things like test data management, service virtualization, test configuration, etc. I hope to continue to build out a full suite of tools that make writing test automation a joy.

Upcoming Talks and a Webinar

I’m going to be busy over the next month. In addition to my usually client work I will be speaking at a couple of conferences. If you are in the area please stop by and say hello. Here’s the list:

I’ll be giving an online Webinar for JetBrains on September 10th. You can read about it here. In this Webinar I will be developing some test automation scripts using Cucumber and I’ll be taking your questions.

I’ll be speaking at the CukeUp conference in New York City on September 17th. Here is a discount code you can use when registering:

After three sold out versions of CukeUp! London, Skills Matter are proud to present the first CukeUp! NYC on September 17th in DUMBO, New York. Under Cucumber creator Aslak Helles√ły’s expert guidance, we’ve put together a fast-paced day packed with talks, discussions, and coding katas. Aslak will be joined by fellow experts and core committers in the Cucumber ecosystem including Peter Bell, Mary Thorn, and Jeff Morgan.

to get involved? We’re giving a special
community 20% discount!

go ahead and enter SkillsMatter_Community
on the booking form and the team at Skills Matter
will look forward to welcoming you to the CukeUp!
NYC this September!

Here’s the description of my talk:

Cucumber gives us Scenarios and Step Definitions and leaves the rest up to us. Over time we have discovered that placing all of our code in Step Definitions tends to lead to brittle tests – especially in very large projects. Join Cheezy as he shows us a few of the tricks he has learned over the years to keep our specification code simple, well factored, and flexible enough to adapt to an ever changing project.

There are a lot of great speakers presenting and if you use cucumber you won’t want to miss this conference.

Finally, I’m speaking at Agile DC. I’m giving a very funny talk about team collaboration. A few lucky attendees from the audience will get to put on costumes and help me with the talk.

Test Automation Bootcamp

I am beginning work on something I call Test Automation Bootcamp. It is an 8 week immersion into the practice of Test Automation. You can read about it here. You can also view the curriculum. I am very excited about putting this together. Please take the time to register on the website if you want to stay informed as things progress.