Main menu

Monthly Archives: March 2017

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:

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.