cucumber - Support for the Page Object pattern in Ruby -


in ruby-land have capybara , webrat drive our web browsers during functional testing cucumber.

what can't find geb in groovy/java-land seems works on 1 level of abstraction higher capybara. description of geb the geb website.

geb browser automation solution.

it brings power of webdriver, elegance of jquery content selection, robustness of page object modelling , expressiveness of groovy language.

capybara brings webdriver (usually selenium) , jquery-style content selection. doesn't have support page object idea. (you create classes represent pages under test, steps carry out actions upon them rather @ dom directly time. mini-api page.)

to give example of kind of useful feature i'm looking for, understand colleague geb can automatically assert page under test matches attributes in virtual page object represents page cucumber tests.

i've made use of site prism page-objects in large application. cheezy's page-object gem other gem considered @ time didn't make use of capybara (which when used correctly can aid timing issues). page-object gem has it's own "wait" mechanism.

there's another gem suspect it's abandoned.

the page-object gem give test code along these lines:

class loginpage   include pageobject    page_url "http://example.com/login"   text_field(:username, :id => 'username')   text_field(:password, :id => 'password')   button(:login, :id => 'login')    def login_with(username, password)     self.username = username     self.password = password     login   end end  # in tests visit_page loginpage |page| page.login_with('testuser1@example.com', 'incorrect') page.wait_until # using default of 30s asynch call   page.text.include? 'invalid user or password' end expect(page).to have_content 'invalid user or password' 

more examples can seen in project: https://github.com/jonkernpa/pageobject , on wiki https://github.com/cheezy/page-object/wiki/elements

site prism looks this:

class loginpage < siteprism::page   set_url '/login'    element :username_field, '#username'   element :password_field, '#password'   element :login_button, '#login'    def login_with(username, password)     username_field.set username     password_field.set password     login_button.click # uses capybara find('#login').click   end end  # in tests @page = loginpage.new @page.load @page.login_with('testuser1@example.com', 'incorrect') # capybara automatically waits expect(@page).to have_content 'invalid user or password' 

the site prism readme has lot of examples. else need know in capybara's excellent readme , documentation.

there of course far more differences these small example shows.
advise take @ both , decide requirements are.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -