Page Object Prototypes Overview¶
Contents
Overview¶
The webdriver_test_tools
package includes pre-defined subclasses of
BasePage
for common
components like forms and navbars. These classes define common methods and
attributes to reduce the amount of code needed to create page objects.
Prototype classes support simplified YAML representations as well as pure Python. This page is an overview of available prototypes and their attributes and pre-defined methods. For details on syntax and example usages, see Page Object Prototype Syntax.
FormObject¶
The FormObject
prototype is used to represent forms, their inputs, and their submit button.
Attributes¶
FormObject
subclasses define the following attributes:
FORM_LOCATOR
: WebDriver locator tuple for the form element
SUBMIT_LOCATOR
: WebDriver locator tuple for the submit button
FormObject
subclasses may also have the following optional attribute:
SUBMIT_SUCCESS_CLASS
: Page object class representing the page/modal/etc that is expected to appear on successful submission
FormObject
subclasses will have the following attributes at runtime. These
are populated based on the contents of YAML_FILE
or INPUT_DICT
:
inputs
: A dictionary mapping input names to the correspondingInputObject
instances
Methods¶
FormObject.fill_inputs
: Fill form inputsFormObject.get_input_values
: Get the current values of form inputsFormObject.submit_is_enabled
: Checks if the submit button is enabledFormObject.click_submit
: Click the submit button
ModalObject¶
The ModalObject
prototype is used to represent modals, their body content, and their close
button.
Attributes¶
ModalObject
subclasses define the following attributes:
MODAL_LOCATOR
: WebDriver locator tuple for the modal element
CLOSE_LOCATOR
: WebDriver locator tuple for the modal close button
ModalObject
subclasses may also have the following optional attribute:
MODAL_BODY_CLASS
: Page object class representing the contents of the modal body
Methods¶
ModalObject.is_displayed
: Checks if the modal is currently visibleModalObject.click_close_button
: Click the modal’s close buttonModalObject.get_modal_body
: Returns an instance of the class defined inMODAL_BODY_CLASS
(orNone
if not set)
WebPageObject¶
The WebPageObject
prototype is used to
represent entire pages.
Attributes¶
WebPageObject
subclasses define the following attribute:
PAGE_URL
: Full URL to the page
WebPageObject
subclasses may also have the following optional attribute:
PAGE_FILENAME
: Filename of the page (or path relative to a base URL configured in a project’sSiteConfig
)
Methods¶
WebPageObject.get_page_title
: Returns the title of the current page