huskypo


Namehuskypo JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/uujohnnyuu/huskyPO
SummaryUI Automation Page Objects design pattern.
upload_time2024-05-04 03:16:54
maintainerNone
docs_urlNone
authorJohnny
requires_pythonNone
licenseApache 2.0
keywords huskypo page object selenium appium automation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # huskyPO

## Copyright
- Developer: Johnny Chou

## Overview
- huskyPO stands for husky Page Object, named 'husky' due to the author's fondness.
- Constructed using Python's data descriptors, it's a UI Page Object package.
- Enables developers to build Python Selenium/Appium UI automation scripts more easily and elegantly.

## Features
- Significantly simplifies and beautifully constructs Page objects and test scripts.
- Encapsulates and integrates commonly used methods of Selenium and Appium, with optimizations in certain functions.
- Uses explicit waiting as the core driving mechanism, and extends some official explicit waiting methods.

## Usage
- Build page objects simply and elegantly using the `Page` and `Element(s)` classes.
- Write test scripts simply and elegantly using the constructed Page objects.

## Example Code
1. First, construct a Page object in any Python file, each page recommended to be a separate Page class.
2. For example, in the my_page.py file:

```python
from huskypo import Page, Element, Elements
from huskypo import By
from huskypo import dynamic

class MyPage(Page):
    
    # Static elements, equivalent to the normal setup of page objects.
    # Similar to constructing Python instance objects.
    search_field = Element(By.NAME, 'q', remark='Search input box')
    search_results = Elements(By.TAG_NAME, 'h3', remark='All search results')
    search_result1 = Element(By.XPATH, '//h3[1]', remark='First search result')

    # Dynamic elements, suitable for special test scenarios where element locator info is decided at runtime during the test case.
    # Typically, dynamic elements make up a very small proportion; if the test environment is robust and stable, it's advisable to mostly use static elements.
    # Dynamic elements need to be written as instance methods of the Page class, and must be decorated with @dynamic to function properly.
    @dynamic
    def search_result(self, order: int = 1):
        return Element(By.XPATH, f'//h3[{order}]', remark=f'Search result no.{order}')

    @dynamic
    def keyword_results(self, keyword: str):
        return Elements(By.XPATH, f'//*[contains(text(), "{keyword}")]')
```

3. After constructing the Page object in my_page.py, you can begin writing test cases.
4. For example, the content of the test_my_page.py file:
```python
from selenium import webdriver
from my_page import MyPage

class TestMyPage:
    
    driver = webdriver.Chrome()
    my_page = MyPage(driver)

    my_page.get("https://google.com")
    my_page.search_field.wait_present()
    my_page.save_screenshot("my/file/path/image.png")

    search_keyword = 'automation'
    my_page.search_field.send_keys(keyword, Keys.ENTER)
    my_page.search_results.wait_any_visible()
    my_page.save_screenshot("my/file/path/image.png")

    assert my_page.keyword_results(search_keyword).quantity > 1
    assert search_keyword in my_page.search_result1.text

    my_page.search_result1.click()
    ...

    driver.close()
```

5. By using the simple examples above, you can see how we can construct Page objects and write scripts intuitively and beautifully with Page, Element(s) classes, and using page.element.method() style.

6. All the element finding processes rely on explicit waiting methods, the core mainly being the official WebDriverWait and expected_conditions, this package extends the commonly used conditions of present, visible, clickable, selected in the Element(s) class and the driver methods and other page-related operations are encapsulated in the Page class.

## TODO
- Continuously monitor new features in Selenium 4.0 / Appium 2.0.
- Keep an eye on potential bugs and performance issues.
- Continue to optimize compatibility with exception handling and type hints.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/uujohnnyuu/huskyPO",
    "name": "huskypo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "huskypo, page object, selenium, appium, automation",
    "author": "Johnny",
    "author_email": "johnny071531@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/73/46/19006b17a8bd23b8b8214f07c64c1d2cef31c675b954696dd517fbb31d8e/huskypo-1.0.2.tar.gz",
    "platform": null,
    "description": "# huskyPO\n\n## Copyright\n- Developer: Johnny Chou\n\n## Overview\n- huskyPO stands for husky Page Object, named 'husky' due to the author's fondness.\n- Constructed using Python's data descriptors, it's a UI Page Object package.\n- Enables developers to build Python Selenium/Appium UI automation scripts more easily and elegantly.\n\n## Features\n- Significantly simplifies and beautifully constructs Page objects and test scripts.\n- Encapsulates and integrates commonly used methods of Selenium and Appium, with optimizations in certain functions.\n- Uses explicit waiting as the core driving mechanism, and extends some official explicit waiting methods.\n\n## Usage\n- Build page objects simply and elegantly using the `Page` and `Element(s)` classes.\n- Write test scripts simply and elegantly using the constructed Page objects.\n\n## Example Code\n1. First, construct a Page object in any Python file, each page recommended to be a separate Page class.\n2. For example, in the my_page.py file:\n\n```python\nfrom huskypo import Page, Element, Elements\nfrom huskypo import By\nfrom huskypo import dynamic\n\nclass MyPage(Page):\n    \n    # Static elements, equivalent to the normal setup of page objects.\n    # Similar to constructing Python instance objects.\n    search_field = Element(By.NAME, 'q', remark='Search input box')\n    search_results = Elements(By.TAG_NAME, 'h3', remark='All search results')\n    search_result1 = Element(By.XPATH, '//h3[1]', remark='First search result')\n\n    # Dynamic elements, suitable for special test scenarios where element locator info is decided at runtime during the test case.\n    # Typically, dynamic elements make up a very small proportion; if the test environment is robust and stable, it's advisable to mostly use static elements.\n    # Dynamic elements need to be written as instance methods of the Page class, and must be decorated with @dynamic to function properly.\n    @dynamic\n    def search_result(self, order: int = 1):\n        return Element(By.XPATH, f'//h3[{order}]', remark=f'Search result no.{order}')\n\n    @dynamic\n    def keyword_results(self, keyword: str):\n        return Elements(By.XPATH, f'//*[contains(text(), \"{keyword}\")]')\n```\n\n3. After constructing the Page object in my_page.py, you can begin writing test cases.\n4. For example, the content of the test_my_page.py file:\n```python\nfrom selenium import webdriver\nfrom my_page import MyPage\n\nclass TestMyPage:\n    \n    driver = webdriver.Chrome()\n    my_page = MyPage(driver)\n\n    my_page.get(\"https://google.com\")\n    my_page.search_field.wait_present()\n    my_page.save_screenshot(\"my/file/path/image.png\")\n\n    search_keyword = 'automation'\n    my_page.search_field.send_keys(keyword, Keys.ENTER)\n    my_page.search_results.wait_any_visible()\n    my_page.save_screenshot(\"my/file/path/image.png\")\n\n    assert my_page.keyword_results(search_keyword).quantity > 1\n    assert search_keyword in my_page.search_result1.text\n\n    my_page.search_result1.click()\n    ...\n\n    driver.close()\n```\n\n5. By using the simple examples above, you can see how we can construct Page objects and write scripts intuitively and beautifully with Page, Element(s) classes, and using page.element.method() style.\n\n6. All the element finding processes rely on explicit waiting methods, the core mainly being the official WebDriverWait and expected_conditions, this package extends the commonly used conditions of present, visible, clickable, selected in the Element(s) class and the driver methods and other page-related operations are encapsulated in the Page class.\n\n## TODO\n- Continuously monitor new features in Selenium 4.0 / Appium 2.0.\n- Keep an eye on potential bugs and performance issues.\n- Continue to optimize compatibility with exception handling and type hints.\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "UI Automation Page Objects design pattern.",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/uujohnnyuu/huskyPO"
    },
    "split_keywords": [
        "huskypo",
        " page object",
        " selenium",
        " appium",
        " automation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "99e43b9eaaa49b7c9b2ff228fae57d41f703730cf1352a130ad9f50201c8d000",
                "md5": "304c092a79460ae25d7e419cfb4fe2a3",
                "sha256": "6f1ec491d7248ab881bb9dbc67735fcbaa6761d29b48452bc803c2db6f8eebac"
            },
            "downloads": -1,
            "filename": "huskypo-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "304c092a79460ae25d7e419cfb4fe2a3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 31060,
            "upload_time": "2024-05-04T03:16:52",
            "upload_time_iso_8601": "2024-05-04T03:16:52.038152Z",
            "url": "https://files.pythonhosted.org/packages/99/e4/3b9eaaa49b7c9b2ff228fae57d41f703730cf1352a130ad9f50201c8d000/huskypo-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "734619006b17a8bd23b8b8214f07c64c1d2cef31c675b954696dd517fbb31d8e",
                "md5": "d2c9f8bc0c3fb39ddb581ed9686b2c6a",
                "sha256": "d9eaf8efe2655457bfb3fd8fab75406ec4e7aae3b48144f32086bd8f222f2781"
            },
            "downloads": -1,
            "filename": "huskypo-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "d2c9f8bc0c3fb39ddb581ed9686b2c6a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 29554,
            "upload_time": "2024-05-04T03:16:54",
            "upload_time_iso_8601": "2024-05-04T03:16:54.302440Z",
            "url": "https://files.pythonhosted.org/packages/73/46/19006b17a8bd23b8b8214f07c64c1d2cef31c675b954696dd517fbb31d8e/huskypo-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-04 03:16:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "uujohnnyuu",
    "github_project": "huskyPO",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "huskypo"
}
        
Elapsed time: 0.25877s