Page Interface

Warning

This is auto-generated interface documentation for the abstract Page class.

This is essential for providing a comprehensive overview of all available methods for the Page object.

For the actual signature, please refer to mops.base.page.Page.

The Page class is a fundamental building block for creating Page Object Models (POM) in web testing. It provides a comprehensive set of methods that allow you to interact with web pages.

These methods could be found below.


class mops.base.page.Page(*args: Any, **kwargs: Any)[source]

Represents a page in a web or mobile application.

The page object encapsulates the necessary logic for interacting with a page using different drivers (Appium, Selenium, Playwright).

This class should be defined for each specific page in the application, encapsulating the page’s Element and groups of elements under Group.

It supports dynamic driver selection and element management based on the current driver.

url: str
log_locator: str | None = None
locator_type: str | None = None
__init__(locator: Locator | str = '', name: str = '', driver_wrapper: DriverWrapper | Any = None)[source]

Initialize a Page based on the current driver.

Parameters:
  • locator (Union[Locator, str]) – The anchor locator of the page. .LocatorType is optional.

  • name (str) – The name of the page, used for logging and identification purposes.

  • driver_wrapper (Union[DriverWrapper, Any]) – The DriverWrapper instance or an object containing it to be used for entire page.

property driver_wrapper: DriverWrapper

Retrieves the driver wrapper instance.

Returns:

The current DriverWrapper instance that assigned for this object.

Return type:

DriverWrapper

property anchor: Element

Return the anchor element of the page

Returns:

:base:`.Element`

reload_page(wait_page_load: bool = True) Page[source]

Reload the current page and optionally wait for the page to fully load.

Parameters:

wait_page_load (bool) – If True, waits until the page is fully loaded and an anchor element is visible. Defaults to True.

Returns:

Page - The current instance of the page object.

open_page(url: str = '') Page[source]

Open a page using the given URL, or use the default URL from the page class if no URL is provided.

Parameters:

url (str) – The URL to navigate to. If not provided, the default URL from the page class will be used.

Returns:

Page - The current instance of the page object.

wait_page_loaded(silent: bool = False, timeout: float = 15) Page[source]

Wait until the page is fully loaded by checking the visibility of the anchor element and other page elements.

Waits for the anchor element to become visible, and depending on the configuration of each page element, it waits for either their visibility or to be hidden.

Parameters:
  • silent (bool) – If True, suppresses logging during the waiting process. Defaults to False.

  • timeout (Union[int, float]) – The maximum time (in seconds) to wait for the page or elements to load. Defaults to WAIT_PAGE.

Returns:

Page - The current instance of the page object.

is_page_opened(with_elements: bool = False, with_url: bool = False) bool[source]

Check whether the current page is opened.

Parameters:
  • with_elements (bool) – If True, verify the page is opened by checking specific elements.

  • with_url (bool) – If True, verify the page is opened by checking the URL.

Returns:

bool - True if the page is opened, otherwise False.

property driver: SeleniumWebDriver | AppiumWebDriver | PlaywrightSourcePage

Retrieves the source driver instance, which could be a Selenium, Appium, or Playwright driver.

Returns:

Current source driver that assigned for this object, which is either n selenium.webdriver.remote.webdriver.WebDriver orn appium.webdriver.webdriver.WebDriver orn playwright.sync_api.Page instance.

log(message: str, level: str = 'info') None

Log a message with detailed context in the following format:

# Format
[time][level][driver_index][module][function:line] <message>
# Example
[Aug 14][16:04:22.767][I][2_driver][play_element.py][is_displayed:328] Check visibility of "Mouse page"
Parameters:
  • message (str) – The log message to record.

  • level (str) – The logging level, which should be one of the values from LogLevel

Returns:

None

swipe(start_x: int, start_y: int, end_x: int, end_y: int, duration: int = 0, sleep: float = 0) Page

Appium only: Swipe from one point to another, with an optional duration and post-swipe delay.

Parameters:
  • start_x (int) – The x-coordinate at which to start the swipe.

  • start_y (int) – The y-coordinate at which to start the swipe.

  • end_x (int) – The x-coordinate at which to end the swipe.

  • end_y (int) – The y-coordinate at which to end the swipe.

  • duration (int) – The duration of the swipe in milliseconds.

  • sleep (Union[int, float]) – The delay (in seconds) after completing the swipe.

Returns:

Page - The current instance of the page object.

swipe_down() Page

Scroll the page downward using a swipe gesture.

Returns:

Page - The current instance of the page object.

swipe_up() Page

Scroll the page upward using a swipe gesture.

Returns:

Page - The current instance of the page object.