-
Notifications
You must be signed in to change notification settings - Fork 6
2 Navigation
Navigation is done with the #self.visit
method:
LoginPage.visit
The easiest means of allowing navigation is to define a page_url
in the Page Object with a basic string:
class LoginPage < WatirDrops::PageObject
page_url { 'http://example.com/login' }
end
Just like with elements, we can pass in a parameter to navigate to a specific instance of a page object:
class UserPage < WatirDrops::PageObject
page_url { |id| "http://example.com/user/#{id}" }
end
This allows you to access different elements by passing in parameters along with the name of the element. So UserPage.visit(10)
is the same as browser.goto("http://example.com/user/10")
If your page object is not merely on a static url page (like a single page app), you can skip defining a page_url
and define the #goto
method directly in the Page Object:
class AddressCreateModal < WatirDrops::PageObject
def goto
AddressPage.visit.add_address.click
end
end
Now AddressCreateModal.visit
will navigate to the AddressPage, then click the add address link and return an instance of AddressCreateModal.