Pages

class stere.Page

Represents a single page in an application. The Page class is the base which all Page Objects should inherit from.

Inheriting from Page is not required for Fields or Areas to work.

All attribute calls that fail are then tried on the browser attribute. This allows classes inheriting from Page to act as a proxy to whichever browser/driver is being used.

Using Splinter’s browser.url method as an example, the following methods are analogous:

>>> MyPage.url == MyPage.browser.url == browser.url

The choice of which syntax to use depends on how you want to write your test suite.

page_url

Get a full URL from Stere’s base_url and a Page’s url_suffix.

Uses urllib.parse.urljoin to combine the two.

navigate()

When the base Stere object has been given the url_navigator attribute, the base_url attribute, and a Page Object has a url_suffix attribute, the navigate() method can be called.

This method will call the method defined in url_navigator, with page_url as the first parameter.

Returns:The instance where navigate() was called from.
Return type:Page

Example

>>> from splinter import Browser
>>> from stere import Page
>>>
>>>
>>> class GuiltyGear(Page):
>>>     def __init__(self):
>>>         self.url_suffix = 'Guilty_Gear'
>>>
>>>
>>> Stere.browser = Browser()
>>> Stere.url_navigator = 'visit'
>>> Stere.base_url = 'https://en.wikipedia.org/'
>>>
>>> guilty_gear_page = GuiltyGear()
>>> guilty_gear_page.navigate()

Using Page as a Context Manager

Page contains __enter__() and __exit__() methods. This allows any page to be used as a Context Manager.

Example:

from pages import Home

with Home() as p:
    p.login_button.click()