views:

284

answers:

2

I'm looking at a cucumber test suite that is somewhat brittle right now; many small steps, and no knowledge of the page itself.

I'd like to factor out the logic involved in the step definitions inside a series of Selenium PageObjects. As seen here.

However, because I'm using Webrat and not Selenium, everything has to go through the Webrat model. So I cannot do

class MyPage < Selenium::WebPage

end

because that adds a direct dependency.

So I have to route everything through Webrat while still maintaining the Selenium Page object goodness. No documentation on this that I can see: if someone has anything on Webrat + PageModel I'd love to see it.

A: 

Turns out the answer is:

class MyPage < BasePage
  def visit
    @world.visit "/"
  end

end

class BasePage
  def initialize(world)
    @world = world
  end
end

And then in a step definition:

Given /I am awesome/ do
  page = MyPage.new(self)
  page.visit
end
Will Sargent
A: 

we just released something that sounds just like what you were after. take a look at Gizmo - http://rubygems.org/gems/gizmo/ works with (webrat | capybara), (cucumber | rspec) etc..

luke cunningham