Page Object Prototypes Overview

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 corresponding InputObject instances

Methods

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

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’s SiteConfig)

Methods