t-page-object


Namet-page-object JSON
Version 0.2.6 PyPI version JSON
download
home_pagehttps://www.thoughtful.ai/
SummaryCookiecutter template for Thoughtful pip package
upload_time2024-12-23 10:08:52
maintainerNone
docs_urlNone
authorThoughtful
requires_python>=3.9
licenseNone
keywords t_page_object
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # T_page_object 📦

> **A Python package for taking an object oriented approach
            when interacting with web pages and their elements .**

## 📑 Table of Contents
- [Overview](#overview)
- [Installation](#installation)
- [Usage Example](#usage-example)
- [API Documentation](#api-documentation)
- [License](#license)

## 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
```bash
pip install t-page-object
```

## Usage Example
For detailed examples, please refer to our
            [quick start page](https://www.notion.so/thoughtfulautomation/T-Page-Object-126f43a78fa480e39a1af8f99f93affe).

### 
## 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:** `BaseApp`
  > Base class for application or portal objects and their configuration.
  - **Method:** `open_browser`
    > Open browser and set Selenium options.
### Module: `t_page_object.base.base_page`

_Contains the BasePage class which is the parent class for all page objects in the project._

- **Class:** `BasePage`
  > Base page class for all page objects in the project.
  - **Method:** `get_element_from_shadow_roots`
    > Get 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:** `visit`
    > Navigate to the base page URL.
  - **Method:** `wait_for_new_window_and_switch`
    > Function 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_load`
    > Wait 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:** `EndpointElement`
  > This is an Endpoint Element used to build each Page.
  - **Method:** `delete`
    > Sends 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:** `get`
    > Sends 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:** `patch`
    > Sends 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:** `post`
    > Sends 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:** `put`
    > Sends 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:** `UIElement`
  > This is an UI Element used to build each Page.
  - **Method:** `format_xpath`
    > If 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_load`
    > 
        Wait 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:** `BotConfig`
  > Class 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:** `ButtonElement`
  > Standard button element.
  - **Method:** `click`
    > Main click method for button element.

        Checks if button is dev_save_sensitive and if dev_safe_mode is enabled.
        
  - **Method:** `click_button`
    > Redirects to click method.
  - **Method:** `click_button_if_visible`
    > Redirects to click method.
  - **Method:** `click_button_when_visible`
    > Redirects to click method.
  - **Method:** `click_element`
    > Redirects to click method.
  - **Method:** `click_element_if_visible`
    > Redirects to click method.
  - **Method:** `click_element_when_clickable`
    > Redirects to click method.
  - **Method:** `click_element_when_visible`
    > Redirects to click method.
### Module: `t_page_object.elements.checkox_element`

_Checkbox element module._

- **Class:** `CheckboxElement`
  > Checkbox element.
  - **Method:** `select`
    > Selects the checkbox element.
### Module: `t_page_object.elements.container_element`

_Class for container elements._

- **Class:** `ContainerElement`
  > Container element. Used to hold multiple text elements.
  - **Method:** `check_if_all_elements_contain_value`
    > Get text for each attribute in object with matching id.
  - **Method:** `get_text_values`
    > Get 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_values`
    > Sets 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:** `DropdownElement`
  > Standard dropdown element.
  - **Method:** `click_and_select_option`
    > Selects 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_option`
    > Gets the selected option.
  - **Method:** `type_and_enter`
    > Selects 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:** `IFrameElement`
  > Class for frame element model.
  - **Method:** `select_iframe`
    > Select frame.
  - **Method:** `select_nested_iframe`
    > Select nested frame.

        Args:
            frames: list of frame locators
            from_base: bool, if True, unselects the current frame before selecting the nested frames
        
  - **Method:** `unselect_iframe`
    > Selects base frame.
### Module: `t_page_object.elements.image_element`

_Image element module._

- **Class:** `ImageElement`
  > Image element.
  - **Method:** `download_image`
    > Download 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:** `InputElement`
  > Input element.
  - **Method:** `click_and_input_text`
    > Input text into element.
  - **Method:** `get_input_value`
    > Get input value.
  - **Method:** `input_text_and_check`
    > 
        Inputs 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
        
### Module: `t_page_object.elements.table_element`

_Table element module._

- **Class:** `TableElement`
  > Table element.
  - **Method:** `get_summary_table_data`
    > Extracts 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_data`
    > Extracts 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:** `TableRowElement`
  > Class for TextElement element model.
  - **Method:** `get_row_values`
    > Get Element value.
### Module: `t_page_object.elements.text_element`

_This module contains the TextElement class for the text element model._

- **Class:** `TextElement`
  > Input element.
  - **Method:** `get_clean_text`
    > Get text from element and clean.

---

## Selenium_manager
### Module: `t_page_object.selenium_manager`

_Create a singleton manager to ensure a single instance of Selenium._

- **Class:** `SeleniumManager`
  > Singleton manager to ensure a single instance of Selenium.

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.thoughtful.ai/",
    "name": "t-page-object",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "t_page_object",
    "author": "Thoughtful",
    "author_email": "support@thoughtful.ai",
    "download_url": "https://files.pythonhosted.org/packages/61/01/e7ca3c05338bca442dfc0cb0189c5ab37afa5d35f6519750484af569aabd/t_page_object-0.2.6.tar.gz",
    "platform": null,
    "description": "# T_page_object \ud83d\udce6\n\n> **A Python package for taking an object oriented approach\n            when interacting with web pages and their elements .**\n\n## \ud83d\udcd1 Table of Contents\n- [Overview](#overview)\n- [Installation](#installation)\n- [Usage Example](#usage-example)\n- [API Documentation](#api-documentation)\n- [License](#license)\n\n## Overview\nThis package provides various modules and classes for creating portals, web pages and web elements.\n            \nThere are also usable web elements that have commonly used methods built in.\n\n## Installation\n```bash\npip install t-page-object\n```\n\n## Usage Example\nFor detailed examples, please refer to our\n            [quick start page](https://www.notion.so/thoughtfulautomation/T-Page-Object-126f43a78fa480e39a1af8f99f93affe).\n\n### \n## API Documentation\n\n---\n\n## Base\n### Module: `t_page_object.base`\n\n_Base objects package for t_page_object._\n\n### Module: `t_page_object.base.base_app`\n\n_Module for BaseApp class._\n\n- **Class:** `BaseApp`\n  > Base class for application or portal objects and their configuration.\n  - **Method:** `open_browser`\n    > Open browser and set Selenium options.\n### Module: `t_page_object.base.base_page`\n\n_Contains the BasePage class which is the parent class for all page objects in the project._\n\n- **Class:** `BasePage`\n  > Base page class for all page objects in the project.\n  - **Method:** `get_element_from_shadow_roots`\n    > Get element from nested shadow roots.\n\n        Args:\n            roots: The css locators of the shadow root elements, in hierarchal order.\n            element_css: The css locator of the element to find.\n\n        Returns:\n            The WebElement of the element found.\n        \n  - **Method:** `visit`\n    > Navigate to the base page URL.\n  - **Method:** `wait_for_new_window_and_switch`\n    > Function for waiting and switching to new window.\n\n        Args:\n            old_window_handles: The list of window handles before the new window is opened.\n\n        Returns:\n            The new window handle.\n        \n  - **Method:** `wait_page_load`\n    > Wait for the page to load by waiting for the verification element to load.\n\n        timeout: The maximum time to wait for the element to be present, in seconds.\n        \n### Module: `t_page_object.base.endpoint_element`\n\n_Contains the EndpointElement class._\n\n- **Class:** `EndpointElement`\n  > This is an Endpoint Element used to build each Page.\n  - **Method:** `delete`\n    > Sends a DELETE request to the specified URL with optional headers and cookies.\n\n        Args:\n            headers: A dictionary containing the request headers. Defaults to an empty dictionary.\n            cookies: A dictionary containing the request cookies. Defaults to an empty dictionary.\n\n        Returns:\n            The response content if the request is successful\n        \n  - **Method:** `get`\n    > Sends a GET request to the specified URL with optional headers, cookies, and parameters.\n\n        Args:\n            headers: A dictionary containing the request headers. Defaults to an empty dictionary.\n            cookies: A dictionary containing the request cookies. Defaults to an empty dictionary.\n            params: A dictionary containing the request parameters. Defaults to an empty dictionary.\n\n        Returns:\n            The response content if the request is successful.\n        \n  - **Method:** `patch`\n    > Sends a PATCH request to the specified URL with optional data, JSON, headers, cookies, and parameters.\n\n        Args:\n            data: The data to send in the request body. Defaults to None.\n            json: The JSON data to send in the request body. Defaults to None.\n            headers: A dictionary containing the request headers. Defaults to an empty dictionary.\n            cookies: A dictionary containing the request cookies. Defaults to an empty dictionary.\n            params: A dictionary containing the request parameters. Defaults to an empty dictionary.\n\n        Returns:\n            The response content if the request is successful.\n        \n  - **Method:** `post`\n    > Sends a POST request to the specified URL with optional data, JSON, headers, cookies, and parameters.\n\n        Args:\n            data: The data to send in the request body. Defaults to None.\n            json: The JSON data to send in the request body. Defaults to None.\n            headers: A dictionary containing the request headers. Defaults to an empty dictionary.\n            cookies: A dictionary containing the request cookies. Defaults to an empty dictionary.\n            params: A dictionary containing the request parameters. Defaults to an empty dictionary.\n\n        Returns:\n            The response content if the request is successful.\n        \n  - **Method:** `put`\n    > Sends a PUT request to the specified URL with optional data, JSON, headers, cookies, and parameters.\n\n        Args:\n            data: The data to send in the request body. Defaults to None.\n            json: The JSON data to send in the request body. Defaults to None.\n            headers: A dictionary containing the request headers. Defaults to an empty dictionary.\n            cookies: A dictionary containing the request cookies. Defaults to an empty dictionary.\n            params: A dictionary containing the request parameters. Defaults to an empty dictionary.\n\n        Returns:\n            The response content if the request is successful\n        \n### Module: `t_page_object.base.ui_element`\n\n_Contains the UIElement class._\n\n- **Class:** `UIElement`\n  > This is an UI Element used to build each Page.\n  - **Method:** `format_xpath`\n    > If using a dynamic xpath, this method formats the xpath string.\n\n        Args:\n            *args (list): The arguments to be used to format the xpath.\n            **kwargs (dict): The keyword arguments to be used to format the\n        \n  - **Method:** `wait_element_load`\n    > \n        Wait for element to load.\n\n        Args:\n            timeout (int, optional): The maximum time to wait for the element to be present, in seconds.\n                Defaults to None. Overwrites apps inherent timeout if set.\n\n        Returns:\n            bool: True if element is visible, False not found and wait is False otherwise.\n\n        Raises:\n            AssertionError: If element is not visible and wait is True.\n        \n\n---\n\n## Bot_config\n### Module: `t_page_object.bot_config`\n\n_Congifuration module for the t_page_object package._\n\n- **Class:** `BotConfig`\n  > Class for configuration.\n\n---\n\n## Elements\n### Module: `t_page_object.elements`\n\n_Module for all base ui components._\n\n### Module: `t_page_object.elements.button_element`\n\n_Button element module._\n\n- **Class:** `ButtonElement`\n  > Standard button element.\n  - **Method:** `click`\n    > Main click method for button element.\n\n        Checks if button is dev_save_sensitive and if dev_safe_mode is enabled.\n        \n  - **Method:** `click_button`\n    > Redirects to click method.\n  - **Method:** `click_button_if_visible`\n    > Redirects to click method.\n  - **Method:** `click_button_when_visible`\n    > Redirects to click method.\n  - **Method:** `click_element`\n    > Redirects to click method.\n  - **Method:** `click_element_if_visible`\n    > Redirects to click method.\n  - **Method:** `click_element_when_clickable`\n    > Redirects to click method.\n  - **Method:** `click_element_when_visible`\n    > Redirects to click method.\n### Module: `t_page_object.elements.checkox_element`\n\n_Checkbox element module._\n\n- **Class:** `CheckboxElement`\n  > Checkbox element.\n  - **Method:** `select`\n    > Selects the checkbox element.\n### Module: `t_page_object.elements.container_element`\n\n_Class for container elements._\n\n- **Class:** `ContainerElement`\n  > Container element. Used to hold multiple text elements.\n  - **Method:** `check_if_all_elements_contain_value`\n    > Get text for each attribute in object with matching id.\n  - **Method:** `get_text_values`\n    > Get text for each element with id matching class attribute.\n\n        Args:\n            cls (Type[TO]): The class to use for the object.\n\n        Returns:\n            Instance of input class with text values.\n        \n  - **Method:** `set_text_values`\n    > Sets text for each element with id matching class attribute.\n\n        Args:\n            cls (Type[TO]): The object to use for the text values.\n        \n### Module: `t_page_object.elements.dropdown_element`\n\n_Dropdown element module._\n\n- **Class:** `DropdownElement`\n  > Standard dropdown element.\n  - **Method:** `click_and_select_option`\n    > Selects an option from the dropdown list based on the provided text.\n\n        The dropdown list is clicked to open the list and the option is selected.\n\n        Args:\n            text_to_find (str): The text of the option to be selected from the dropdown list.\n            option_tag (str, optional): The tag of the option to be selected from the dropdown list. Defaults to 'li'.\n\n        Returns:\n            None\n        \n  - **Method:** `get_selected_option`\n    > Gets the selected option.\n  - **Method:** `type_and_enter`\n    > Selects an option from the dropdown list based on the provided text.\n\n        The text is input into the dropdown list input and the Enter key is pressed to select the option.\n\n        Args:\n            text_to_enter (str): The text/s of the option to be selected from the dropdown list.\n            option_tag (str): The tag used for the different options. Defaults to 'li'.\n\n        Returns:\n            None\n        \n### Module: `t_page_object.elements.iframe_element`\n\n_Frame element module._\n\n- **Class:** `IFrameElement`\n  > Class for frame element model.\n  - **Method:** `select_iframe`\n    > Select frame.\n  - **Method:** `select_nested_iframe`\n    > Select nested frame.\n\n        Args:\n            frames: list of frame locators\n            from_base: bool, if True, unselects the current frame before selecting the nested frames\n        \n  - **Method:** `unselect_iframe`\n    > Selects base frame.\n### Module: `t_page_object.elements.image_element`\n\n_Image element module._\n\n- **Class:** `ImageElement`\n  > Image element.\n  - **Method:** `download_image`\n    > Download images using RPA.HTTP and return the local path.\n\n        Args:\n            download_path (str, optional): The path to save the downloaded image. Defaults to output_folder.\n\n        Returns:\n            str: The path of the downloaded image.\n        \n### Module: `t_page_object.elements.input_element`\n\n_Input element module._\n\n- **Class:** `InputElement`\n  > Input element.\n  - **Method:** `click_and_input_text`\n    > Input text into element.\n  - **Method:** `get_input_value`\n    > Get input value.\n  - **Method:** `input_text_and_check`\n    > \n        Inputs the given text into an element and verifies the input.\n\n        Args:\n            text (str): The text to input into the element.\n            tries (int, optional): The number of attempts to verify the text input. Defaults to 5.\n\n        Returns:\n            None\n        \n### Module: `t_page_object.elements.table_element`\n\n_Table element module._\n\n- **Class:** `TableElement`\n  > Table element.\n  - **Method:** `get_summary_table_data`\n    > Extracts and structures data from an HTML summary table into a list of dictionaries.\n\n        This method locates the table headers and body rows, then iterates over them to extract the data.\n        Each row of the table is represented as a dictionary.\n\n        Returns:\n            list: A list of dictionaries, where each dictionary represents a row in the table.\n                Each dictionary key is a column header, and each value is the corresponding data\n                from that column in the row.\n        \n  - **Method:** `get_table_data`\n    > Extracts data from an HTML table.\n\n        This method locates table headers and body elements, then iterates over them to extract and structure the data\n        into a dictionary.\n\n        Args:\n            table_orientation (str): The orientation of the table. Can be either 'vertical' or 'horizontal'.\n                Defaults to 'vertical'.\n\n        Returns:\n            list: A list where each item is a dict representing a table. Each dict has column headers\n                as keys and a list for all column values\n        \n### Module: `t_page_object.elements.table_row_element`\n\n_Table Row element module._\n\n- **Class:** `TableRowElement`\n  > Class for TextElement element model.\n  - **Method:** `get_row_values`\n    > Get Element value.\n### Module: `t_page_object.elements.text_element`\n\n_This module contains the TextElement class for the text element model._\n\n- **Class:** `TextElement`\n  > Input element.\n  - **Method:** `get_clean_text`\n    > Get text from element and clean.\n\n---\n\n## Selenium_manager\n### Module: `t_page_object.selenium_manager`\n\n_Create a singleton manager to ensure a single instance of Selenium._\n\n- **Class:** `SeleniumManager`\n  > Singleton manager to ensure a single instance of Selenium.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Cookiecutter template for Thoughtful pip package",
    "version": "0.2.6",
    "project_urls": {
        "Homepage": "https://www.thoughtful.ai/"
    },
    "split_keywords": [
        "t_page_object"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6101e7ca3c05338bca442dfc0cb0189c5ab37afa5d35f6519750484af569aabd",
                "md5": "d3bfd827fe18c8f0c0b9dab2439caabe",
                "sha256": "1ab95ed9b2d468b52d4b910d994a980132afaafd26f5e407ff9de6889b0feb7b"
            },
            "downloads": -1,
            "filename": "t_page_object-0.2.6.tar.gz",
            "has_sig": false,
            "md5_digest": "d3bfd827fe18c8f0c0b9dab2439caabe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 20258,
            "upload_time": "2024-12-23T10:08:52",
            "upload_time_iso_8601": "2024-12-23T10:08:52.232003Z",
            "url": "https://files.pythonhosted.org/packages/61/01/e7ca3c05338bca442dfc0cb0189c5ab37afa5d35f6519750484af569aabd/t_page_object-0.2.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-23 10:08:52",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "t-page-object"
}
        
Elapsed time: 0.65280s