andyw8 / capybara-page-object

MIT License
32 stars 9 forks source link

PageObjects Pattern #3

Open bpinto opened 12 years ago

bpinto commented 12 years ago

One commonly seen pattern with PageObjects is to check that the WebDriver is on the correct page when we instantiate the PageObject.

With the current approach, this is not possible. One of the reason is that the path method is a instance method instead of a class method. Otherwise, we could do modifications as such (draft):

def initialize
    self.source.current_path.should == self.prefix + self.path
    self
end

def self.visit(attr={})
    Capybara.current_session.visit visit_path(attr)
            new
end

Ref: http://code.google.com/p/selenium/wiki/PageObjects

andyw8 commented 12 years ago

Thanks, I will consider this.