page-object 0.5.4 released

*** You are calling a method named table.
*** This method does not exist in page-object so it is being passed to the driver.
*** This feature will be removed in the near future.
*** Please change your code to call the correct page-object method.
*** If you are using functionality that does not exist in page-object please request it be added.

You might see a warning similar to this one when you use the new page-object release. I am planning on removing something that current exists in the gem. This post will explain what and why.


When the page-object gem was young there was a significant amount of functionality that existed in the native drivers (watir-webdriver and selenium-webdriver) that was not exposed via the page-object gem. At that time I decided to override method_missing in the Element class to directly delegate all unknown calls to the underlying native element. This was a work around to make it easier for the users to use these capabilities while I was busy adding all necessary functionality into the page-object gem.

I will be removing this capability in about two months. At that time you will get an error when you call a method on an Element that doesn’t exist. The warning message should provide guidance to you on what you will need to change over the next two months.


Some of you may wonder why I am removing this feature. While it seemed like a good idea at the time I added this capability, it has been the source of most of the support I have provided for users. Many have found it confusing having both page-object and Watir calls mixed together and many errors resulted. At this point, over three fourths of the problems I help people with are directly related to these calls being used together. In almost every case the solution is to only use the page-object elements and methods.

What should I do?

You should run your scripts and note where these warnings occur. When you see them you should adjust your code to use the page-object methods and objects. If you do find that there is some feature you need that is currently not supported by page-object please go to the issues page and open an issue. I will respond to it as soon as possible.

9 thoughts on “page-object 0.5.4 released

  1. Interesting work on this framework.

    I have been curious about something. Why have you chosen to support both Selenium and Watir with this framework? I ask because it seems like with Watir-WebDriver, you can drop down into Selenium if you need to (via @browser.driver, for example). Watir seems to present a nicer way to chain methods and is a bit more readable than Selenium.

    I realize your framework is providing a sort of common platform for the two libraries, but I was just wondering what motivated you to want to go a “common platform” approach — i.e., support both as opposed to just one?

    • Jeff, thanks for the question. My rationale to support both goes beyond the two gems. There are several additional gems that allow you to run your tests in grids, distributed across multiple servers, gather performance statistics, etc. In some cases selenium offers the best overall package and in some cases watir does. Having the ability for my scripts to run with either allows me to take advantage of all of the cool things that are taking place in the community.

    • I will be adding methods that have been requested. I think you will find that nearly everything is there already. For example, .exist? is a method on Element.

      • That’s odd because I keep getting the deprecation warning for .exist?

        It’s hard to tell (since I’m not yet sure what line in my code is throwing the warning) , but maybe it’s not an Element I’ve put that method on…

      • Scratch that, it is an element:


        I just now updated to 0.6, so maybe this will go away.

        Also, can I get a “.disabled?” for checking if a field is read only?

  2. Do you happen to have any examples of how to use tables? I did see your feature files but none of those really cover how someone would actually use a table when you don’t know the exact rows and columns you will have. For example, I would want to do something like this:

    Given I am on the results page
    When the results table exists
    And the row for “Offshort Accounts” is found
    Then the column “Valuation” should be “$2,410,905.00”

    In other words, I’d want to cycle through the rows of a table to find one that had “Offshore Accounts” in its Name column. Then I would check the column “Valuation” in that same row for a specific value. It’s not clear to me how to do that.

    I looked through the source but it’s not clear to me how the TableCell, TableRow and Table elements can be used together.

    • Here’s an example that demonstrates what you want:

      class MyPage
      include PageObject

      NAME = 0
      AMOUNT = 1

      table(:accounts, :id => 'account_id')

      def find_amount_for(account_name)
      row = accounts_element.find {|row| row[NAME].text == account_name}


      In the find_amount_for method I’m looking through each row attempting to match the first column’s text with the provided value. This returns the row. Once I have the row I simply return the second column which has the amount.

      Let me know if this is not clear.


Leave a Reply

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