-
Notifications
You must be signed in to change notification settings - Fork 220
Creating and using page objects
cheezy edited this page Jul 26, 2011
·
10 revisions
Alister Scott blogged about an idea for creating a factory to create instances of page objects. In the past I have blogged about page objects returning page objects. After a lot of contemplation, I am completely in the Alister camp. page-object
now supports this approach as well.
A module named PageFactory
provides this ability. This method has two methods.
def visit_page(page_class, &block)
def on_page(page_class, visit=false, &block)
Let's take a look at how you would use these method in your cucumber scripts.
Given /^I am on the registration page$/ do
visit_page RegistrationPage
end