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

Closed
zeljkofilipin opened this Issue Jun 12, 2012 · 9 comments

Comments

Projects
None yet
8 participants
@zeljkofilipin
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.

Examples:

HTMLwatirpage-object
tdtdcell
hiddenhiddenhidden_field
imgimgimage
aalink
lililist_item
ololordered_list
ppparagraph
input type="radio"radioradio_button
selectselectselect_list
tdtdcell
textareatextareatext_area
ululunordered_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

This comment has been minimized.

Copy link

knorrium commented Jun 12, 2012

+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

This comment has been minimized.

Copy link

fgeorge commented Jun 12, 2012

+1

@lisacrispin

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

@bret

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.

@zeljkofilipin

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

bret commented Jun 15, 2012

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

@cheezy

This comment has been minimized.

Copy link
Owner

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

@dilli-raja

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|
text_field(:first_name,:id=>'ts_first_name',:frame=>frame)
end

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

end

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

@AlanLGuy

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.