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 <开发者_StackOverflow 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.
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
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..
精彩评论