Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
zeljkofilipin opened this Issue · 7 comments

6 participants

@zeljkofilipin

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.

Examples:

HTML watir page-object
td td cell
hidden hidden hidden_field
img img image
a a link
li li list_item
ol ol ordered_list
p p paragraph
input type="radio" radio radio_button
select select select_list
td td cell
textarea textarea text_area
ul ul unordered_list

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): http://watirmelon.com/2012/06/04/roll-your-own-page-objects/

@knorrium

+1

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 :)

@fgeorge

+1

@lisacrispin

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).

@bret

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.

@zeljkofilipin

@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
@bret

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

@cheezy
Owner

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.