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
Elementand groups of elements underGroup.It supports dynamic driver selection and element management based on the current driver.
- __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
DriverWrapperinstance or an object containing it to be used for entire page.
- property driver_wrapper: DriverWrapper¶
Retrieves the driver wrapper instance.
- Returns:
The current
DriverWrapperinstance that assigned for this object.- Return type:
- reload_page(wait_page_load: bool = True) Page[source]¶
Reload the current page and optionally wait for the page to fully load.
- 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.
- 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.
- is_page_opened(with_elements: bool = False, with_url: bool = False) bool[source]¶
Check whether the current page is opened.
- 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.WebDriverornappium.webdriver.webdriver.WebDriverornplaywright.sync_api.Pageinstance.
- 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"
- 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.