capybara-page-object icon indicating copy to clipboard operation
capybara-page-object copied to clipboard

PageObjects Pattern

Open bpinto opened this issue 12 years ago • 1 comments

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

bpinto avatar May 09 '12 16:05 bpinto

Thanks, I will consider this.

andyw8 avatar May 13 '12 14:05 andyw8