Cookiecutter template for Thoughtful pip package
Project description
T_page_object 📦
A Python package for taking an object oriented approach when interacting with web pages and their elements .
📑 Table of Contents
Overview
This package provides various modules and classes for creating portals, web pages and web elements.
There are also usable web elements that have commonly used methods built in.
Installation
pip install t-page-object
Usage Example
For detailed examples, please refer to our quick start page.
Performance Suite
The package includes a performance testing suite that measures the execution time of various page interactions. This helps in identifying performance bottlenecks and ensuring optimal performance when interacting with web elements.
What is the Performance Suite?
The performance suite is a collection of tests that measure the execution time for:
- Page loading
- Element interactions (clicks, form filling, etc.)
- DOM manipulation
- Alert handling
Tests are run against various demo websites to provide a comprehensive performance profile.
Running the Performance Suite
To run the performance suite:
# Make sure you have the development requirements installed
pip install -r dev_requirements.txt
# Run the performance tests
CAPTCHA_GURU_API_KEY=XXX PYTHONPATH=. python performance/runner.py
Results are saved to performance/outputs/ with timestamps for tracking performance over time.
When running in CI/CD environments, you can use a Selenium Grid with:
PYTHONPATH=. SELENIUM_GRID_URL=http://localhost:4444/wd/hub python performance/runner.py
API Documentation
Base
Module: t_page_object.base
Base objects package for t_page_object.
Module: t_page_object.base.base_app
Module for BaseApp class.
- Class:
BaseAppBase class for application or portal objects and their configuration.
- Method:
open_browserOpen browser and set Selenium options.
- Method:
Module: t_page_object.base.base_page
Contains the BasePage class which is the parent class for all page objects in the project.
- Class:
BasePageBase page class for all page objects in the project.
-
Method:
get_element_from_shadow_rootsGet element from nested shadow roots.
Args: roots: The css locators of the shadow root elements, in hierarchal order. element_css: The css locator of the element to find. Returns: The WebElement of the element found. -
Method:
visitNavigate to the base page URL.
-
Method:
wait_for_new_window_and_switchFunction for waiting and switching to new window.
Args: old_window_handles: The list of window handles before the new window is opened. Returns: The new window handle. -
Method:
wait_page_loadWait for the page to load by waiting for the verification element to load.
timeout: The maximum time to wait for the element to be present, in seconds.
-
Module: t_page_object.base.endpoint_element
Contains the EndpointElement class.
- Class:
EndpointElementThis is an Endpoint Element used to build each Page.
-
Method:
deleteSends a DELETE request to the specified URL with optional headers and cookies.
Args: headers: A dictionary containing the request headers. Defaults to an empty dictionary. cookies: A dictionary containing the request cookies. Defaults to an empty dictionary. Returns: The response content if the request is successful -
Method:
getSends a GET request to the specified URL with optional headers, cookies, and parameters.
Args: headers: A dictionary containing the request headers. Defaults to an empty dictionary. cookies: A dictionary containing the request cookies. Defaults to an empty dictionary. params: A dictionary containing the request parameters. Defaults to an empty dictionary. Returns: The response content if the request is successful. -
Method:
patchSends a PATCH request to the specified URL with optional data, JSON, headers, cookies, and parameters.
Args: data: The data to send in the request body. Defaults to None. json: The JSON data to send in the request body. Defaults to None. headers: A dictionary containing the request headers. Defaults to an empty dictionary. cookies: A dictionary containing the request cookies. Defaults to an empty dictionary. params: A dictionary containing the request parameters. Defaults to an empty dictionary. Returns: The response content if the request is successful. -
Method:
postSends a POST request to the specified URL with optional data, JSON, headers, cookies, and parameters.
Args: data: The data to send in the request body. Defaults to None. json: The JSON data to send in the request body. Defaults to None. headers: A dictionary containing the request headers. Defaults to an empty dictionary. cookies: A dictionary containing the request cookies. Defaults to an empty dictionary. params: A dictionary containing the request parameters. Defaults to an empty dictionary. Returns: The response content if the request is successful. -
Method:
putSends a PUT request to the specified URL with optional data, JSON, headers, cookies, and parameters.
Args: data: The data to send in the request body. Defaults to None. json: The JSON data to send in the request body. Defaults to None. headers: A dictionary containing the request headers. Defaults to an empty dictionary. cookies: A dictionary containing the request cookies. Defaults to an empty dictionary. params: A dictionary containing the request parameters. Defaults to an empty dictionary. Returns: The response content if the request is successful
-
Module: t_page_object.base.ui_element
Contains the UIElement class.
- Class:
UIElementThis is an UI Element used to build each Page.
-
Method:
format_xpathIf using a dynamic xpath, this method formats the xpath string.
Args: *args (list): The arguments to be used to format the xpath. **kwargs (dict): The keyword arguments to be used to format the -
Method:
wait_element_loadWait for element to load. Args: timeout (int, optional): The maximum time to wait for the element to be present, in seconds. Defaults to None. Overwrites apps inherent timeout if set. Returns: bool: True if element is visible, False not found and wait is False otherwise. Raises: AssertionError: If element is not visible and wait is True.
-
Bot_config
Module: t_page_object.bot_config
Congifuration module for the t_page_object package.
- Class:
BotConfigClass for configuration.
Elements
Module: t_page_object.elements
Module for all base ui components.
Module: t_page_object.elements.button_element
Button element module.
- Class:
ButtonElementStandard button element.
-
Method:
clickMain click method for button element.
Checks if button is dev_save_sensitive and if dev_safe_mode is enabled. -
Method:
click_buttonRedirects to click method.
-
Method:
click_button_if_visibleRedirects to click method.
-
Method:
click_button_when_visibleRedirects to click method.
-
Method:
click_elementRedirects to click method.
-
Method:
click_element_if_visibleRedirects to click method.
-
Method:
click_element_when_clickableRedirects to click method.
-
Method:
click_element_when_visibleRedirects to click method.
-
Module: t_page_object.elements.checkbox_element
Checkbox element module.
- Class:
CheckboxElementCheckbox element.
- Method:
selectSelects the checkbox element.
- Method:
Module: t_page_object.elements.container_element
Class for container elements.
- Class:
ContainerElementContainer element. Used to hold multiple text elements.
-
Method:
check_if_all_elements_contain_valueGet text for each attribute in object with matching id.
-
Method:
get_text_valuesGet text for each element with id matching class attribute.
Args: cls (Type[TO]): The class to use for the object. Returns: Instance of input class with text values. -
Method:
set_text_valuesSets text for each element with id matching class attribute.
Args: cls (Type[TO]): The object to use for the text values.
-
Module: t_page_object.elements.dropdown_element
Dropdown element module.
- Class:
DropdownElementStandard dropdown element.
-
Method:
click_and_select_optionSelects an option from the dropdown list based on the provided text.
The dropdown list is clicked to open the list and the option is selected. Args: text_to_find (str): The text of the option to be selected from the dropdown list. option_tag (str, optional): The tag of the option to be selected from the dropdown list. Defaults to 'li'. Returns: None -
Method:
get_selected_optionGets the selected option.
-
Method:
type_and_enterSelects an option from the dropdown list based on the provided text.
The text is input into the dropdown list input and the Enter key is pressed to select the option. Args: text_to_enter (str): The text/s of the option to be selected from the dropdown list. option_tag (str): The tag used for the different options. Defaults to 'li'. Returns: None
-
Module: t_page_object.elements.iframe_element
Frame element module.
- Class:
IFrameElementClass for frame element model.
-
Method:
select_iframeSelect frame.
-
Method:
select_nested_iframeSelect nested frame.
Args: frames: list of frame locators from_base: bool, if True, unselects the current frame before selecting the nested frames -
Method:
unselect_iframeSelects base frame.
-
Module: t_page_object.elements.image_element
Image element module.
- Class:
ImageElementImage element.
-
Method:
download_imageDownload images using RPA.HTTP and return the local path.
Args: download_path (str, optional): The path to save the downloaded image. Defaults to output_folder. Returns: str: The path of the downloaded image.
-
Module: t_page_object.elements.input_element
Input element module.
- Class:
InputElementInput element.
- Method:
click_and_input_textInput text into element.
- Method:
get_input_valueGet input value.
- Method:
input_text_and_checkInputs the given text into an element and verifies the input. Args: text (str): The text to input into the element. tries (int, optional): The number of attempts to verify the text input. Defaults to 5. Returns: None
- Method:
Module: t_page_object.elements.table_element
Table element module.
- Class:
TableElementTable element.
-
Method:
get_summary_table_dataExtracts and structures data from an HTML summary table into a list of dictionaries.
This method locates the table headers and body rows, then iterates over them to extract the data. Each row of the table is represented as a dictionary. Returns: list: A list of dictionaries, where each dictionary represents a row in the table. Each dictionary key is a column header, and each value is the corresponding data from that column in the row. -
Method:
get_table_dataExtracts data from an HTML table.
This method locates table headers and body elements, then iterates over them to extract and structure the data into a dictionary. Args: table_orientation (str): The orientation of the table. Can be either 'vertical' or 'horizontal'. Defaults to 'vertical'. Returns: list: A list where each item is a dict representing a table. Each dict has column headers as keys and a list for all column values
-
Module: t_page_object.elements.table_row_element
Table Row element module.
- Class:
TableRowElementClass for TextElement element model.
- Method:
get_row_valuesGet Element value.
- Method:
Module: t_page_object.elements.text_element
This module contains the TextElement class for the text element model.
- Class:
TextElementInput element.
- Method:
get_clean_textGet text from element and clean.
- Method:
Selenium_manager
Module: t_page_object.selenium_manager
Create a singleton manager to ensure a single instance of Selenium.
- Class:
SeleniumManagerSingleton manager to ensure a single instance of Selenium.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file t_page_object-1.0.5.tar.gz.
File metadata
- Download URL: t_page_object-1.0.5.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbb5a6b4f4ebcaf87eae772d88a9f5aba1a27223e8a82efeb0f57a8d6c39a771
|
|
| MD5 |
48bc749165aa467579464bb5478bf7c2
|
|
| BLAKE2b-256 |
a041dbb4fe8d52fcf2bf7db90d71a6a26c08385a9b58eb92ad9a57082af58501
|