Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

page-object API should be more similar to watir API #102

zeljkofilipin opened this Issue Jun 12, 2012 · 9 comments


None yet
8 participants
Copy link

zeljkofilipin commented Jun 12, 2012

I am pretty sure I am not the only one that has experience with watir API, and gets confused because page-object gem uses different names for some page elements.


input type="radio"radioradio_button

I am all for making the API human-friendly, that is what watir tried to do in the beginning. After a few years we have noticed that people are getting confused with the API that sometimes uses the same names as HTML, and sometimes does not.

I would suggest that you leave the existing API as is and to create aliases for the people that are familiar with HTML and watir APIs.

Example: we should be able to access unordered list with both unordered_list and ul.

For more people thinking page-object API should be more similar to watir API, take a look at Alister's blog post (and comments):


This comment has been minimized.

Copy link

knorrium commented Jun 12, 2012


I'm using Watir again and decided to catch up with what the cool kids are using nowadays (read: page-object :) and had a hard time adopting the different API. A lot of method calls were "deprecated".

It would be great to have aliases for the Watir API.

Thanks for bringing this up, Z :)


This comment has been minimized.

Copy link

fgeorge commented Jun 12, 2012



This comment has been minimized.

Copy link

lisacrispin commented Jun 12, 2012

We're using the page object pattern with Robot Framework / Se2Library (web driver) and I am LOVING it now that I've got traction on it. Cheezy helped my team learn how to do this, so though we aren't using his Ruby gem, I expect we are doing something similar.

I got stuck back on an old version of Watir and never had the time to update all our scripts so we could upgrade to Watir 2. I never had any issues with the api. But, I find it easy to figure out the HTML, I'm not sure it's necessary to make it any easier. I think the hard part is understanding the page object pattern and how to use it properly, and with Watir, the way hardest part is learning Ruby and learning how to design the scripts well (which I assume Cheezy's gem assists with).


This comment has been minimized.

Copy link

bret commented Jun 14, 2012

Seems like the Page Object gem is closer to the Watir 1.0 API whereas Watir 2.0 has moved to be more like HTML. The page object gem also seems to move more in the spirit of the 1.0 api, using common names for elements instead of their HTML. Just observing. We use a different page object pattern at Blackbaud where we just have a generic "keyword" command that works for all types and wraps full watir expressions, so we don't really have this problem in the first place. Always happy to see the enthusiasm for this kind of collaboration.


This comment has been minimized.

Copy link

zeljkofilipin commented Jun 14, 2012

@bret could you please share the code how would this look like in your API?

browser.button(:id => 'an_id') # watir
button(:your_name, :id => 'an_id') # page-object

This comment has been minimized.

Copy link

bret commented Jun 15, 2012

keyword :your_name {browser.button(:id => 'an_id')}


This comment has been minimized.

Copy link

cheezy commented Jul 15, 2012

With the release I'm about to make I have added the following aliases:

a => link
hidden => hidden_field
img => image
li => list_item
ol => ordered_list
p => paragraph
radio => radio_button
select => select_list
td => cell
textarea => text_area
ul => unordered_list

I believe this addresses all of the issues zeljkofilipin pointed out so I am going to close this issue. Expect a release within the hour.

@cheezy cheezy closed this Jul 15, 2012


This comment has been minimized.

Copy link

dilli-raja commented Nov 25, 2015

class TestPageObjectAccessor
include PageObject

in_frame(:id=>'ts_frame_01')do |frame|

def perform_text_actions
self.your_name="Raja" ; sleep 3


I cant able to create keyword for this code.@bret could you please help me out ?


This comment has been minimized.

Copy link

AlanLGuy commented Nov 26, 2015

I don't know what you mean by "keyword", but you haven't defined #your_name anywhere... You have a #first_name element defined though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.