===============================================================================
Pomcorn
===============================================================================
.. image:: https://img.shields.io/github/actions/workflow/status/saritasa-nest/pomcorn/pre-commit.yml
:target: https://img.shields.io/
:alt: GitHub Workflow Status (with event)
.. image:: https://img.shields.io/pypi/v/pomcorn
:target: https://img.shields.io/
:alt: PyPI
.. image:: https://img.shields.io/pypi/status/pomcorn
:target: https://img.shields.io/
:alt: PyPI - Status
.. image:: https://img.shields.io/pypi/pyversions/pomcorn
:target: https://img.shields.io/
:alt: PyPI - Python Version
.. image:: https://img.shields.io/pypi/l/pomcorn
:target: https://img.shields.io/
:alt: PyPI - License
.. image:: https://img.shields.io/pypi/dm/pomcorn
:target: https://img.shields.io/
:alt: PyPI - Downloads
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Code style: black
.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336
:target: https://pycqa.github.io/isort/
:alt: Imports: isort
**Pomcorn**, or **Page Object Model corn**, is a Python package that contains base classes to create
systems based on `Selenium <https://github.com/SeleniumHQ/selenium#selenium>`_ framework and
**Page Object Model** pattern. You can read more about this pattern
`here <https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/>`_.
The package can be used to create autotesting systems, parsing scripts and anything that requires
interaction with the browser.
The package includes next base classes to create Page Object Model (``POM``) pages:
.. image:: docs/_static/images/class_diagram.png
:alt: Class diagram
It also includes
`classes to locate elements <https://pomcorn.readthedocs.io/en/latest/locators.html>`_
on the web page and a number of additional
`waiting conditions <https://pomcorn.readthedocs.io/en/latest/waits_conditions.html>`_.
*******************************************************************************
Installation
*******************************************************************************
You can install it by **pip**:
.. code-block:: console
$ pip install pomcorn
Or **poetry**:
.. code-block:: console
$ poetry add pomcorn
*******************************************************************************
Documentation
*******************************************************************************
Link to the documentation: http://pomcorn.rtfd.io/.
*******************************************************************************
Usage
*******************************************************************************
You need to
`install pomcorn <https://pomcorn.readthedocs.io/en/latest/installation.html>`_ and
`Chrome webdriver <https://pomcorn.readthedocs.io/en/latest/installation.html#chrome-driver>`_.
Below is the code that opens ``PyPI.org``, searches for packages by name and prints names of found
packages to the terminal. The script contains all base classes contained in ``pomcorn``: **Page**,
**ComponentWithBaseLocator**, **ListComponent** and **Element**.
.. code-block:: python
from typing import Self
from selenium.webdriver import Chrome
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.remote.webdriver import WebDriver
from pomcorn import ComponentWithBaseLocator, Element, ListComponent, Page, locators
# Prepare base page
class PyPIPage(Page):
APP_ROOT = "https://pypi.org"
def check_page_is_loaded(self) -> bool:
return self.init_element(locators.TagNameLocator("main")).is_displayed
@property
def search(self) -> Element[locators.XPathLocator]:
return self.init_element(locators.IdLocator("search"))
# Prepare components
Package = ComponentWithBaseLocator[PyPIPage]
class PackageList(ListComponent[Package, PyPIPage]):
item_class = Package
@property
def base_item_locator(self) -> locators.XPathLocator:
return self.base_locator // locators.ClassLocator("snippet__name")
@property
def names(self) -> list[str]:
return [package.body.get_text() for package in self.all]
# Prepare search page
class SearchPage(PyPIPage):
@classmethod
def open(cls, webdriver: WebDriver, **kwargs) -> Self:
pypi_page = super().open(webdriver, **kwargs)
# Specific logic for PyPI for an open search page
pypi_page.search.fill("")
pypi_page.search.send_keys(Keys.ENTER)
return cls(webdriver, **kwargs)
@property
def results(self) -> PackageList:
return PackageList(
page=self,
base_locator=locators.PropertyLocator(
prop="aria-label",
value="Search results",
),
)
def find(self, query: str) -> PackageList:
self.search.fill(query)
self.search.send_keys(Keys.ENTER)
return self.results
search_page = SearchPage.open(webdriver=Chrome())
print(search_page.find("saritasa").names)
For more information about package classes, you can read in `Object Hierarchy <https://pomcorn.readthedocs.io/en/latest/objects_hierarchy.html>`_
and `Developer Interface <https://pomcorn.readthedocs.io/en/latest/developer_interface.html>`_.
Also you can try our `demo autotests project <https://pomcorn.readthedocs.io/en/latest/demo.html>`_.
Raw data
{
"_id": null,
"home_page": "https://pypi.org/project/pomcorn/",
"name": "pomcorn",
"maintainer": "Anton Oboleninov",
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": "anton.oboleninov@saritasa.com",
"keywords": "python, selenium, webdriver, autotests, page object model, page object pattern, page object, pom, parsing, browser",
"author": "Saritasa",
"author_email": "pypi@saritasa.com",
"download_url": "https://files.pythonhosted.org/packages/c9/83/64bcfb9027425f5ce1edd93ae9353c2ebdf2a0041a6513bae1e74ab63391/pomcorn-0.6.0.tar.gz",
"platform": null,
"description": "===============================================================================\nPomcorn\n===============================================================================\n\n.. image:: https://img.shields.io/github/actions/workflow/status/saritasa-nest/pomcorn/pre-commit.yml\n\t:target: https://img.shields.io/\n\t:alt: GitHub Workflow Status (with event)\n\n.. image:: https://img.shields.io/pypi/v/pomcorn\n\t:target: https://img.shields.io/\n\t:alt: PyPI\n\n.. image:: https://img.shields.io/pypi/status/pomcorn\n\t:target: https://img.shields.io/\n\t:alt: PyPI - Status\n\n.. image:: https://img.shields.io/pypi/pyversions/pomcorn\n\t:target: https://img.shields.io/\n\t:alt: PyPI - Python Version\n\n.. image:: https://img.shields.io/pypi/l/pomcorn\n\t:target: https://img.shields.io/\n\t:alt: PyPI - License\n\n.. image:: https://img.shields.io/pypi/dm/pomcorn\n\t:target: https://img.shields.io/\n\t:alt: PyPI - Downloads\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n\t:target: https://github.com/psf/black\n\t:alt: Code style: black\n\n.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336\n\t:target: https://pycqa.github.io/isort/\n\t:alt: Imports: isort\n\n\n**Pomcorn**, or **Page Object Model corn**, is a Python package that contains base classes to create\nsystems based on `Selenium <https://github.com/SeleniumHQ/selenium#selenium>`_ framework and\n**Page Object Model** pattern. You can read more about this pattern\n`here <https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/>`_.\nThe package can be used to create autotesting systems, parsing scripts and anything that requires\ninteraction with the browser.\n\nThe package includes next base classes to create Page Object Model (``POM``) pages:\n\n.. image:: docs/_static/images/class_diagram.png\n :alt: Class diagram\n\nIt also includes\n`classes to locate elements <https://pomcorn.readthedocs.io/en/latest/locators.html>`_\non the web page and a number of additional\n`waiting conditions <https://pomcorn.readthedocs.io/en/latest/waits_conditions.html>`_.\n\n*******************************************************************************\nInstallation\n*******************************************************************************\n\nYou can install it by **pip**:\n\n.. code-block:: console\n\n $ pip install pomcorn\n\nOr **poetry**:\n\n.. code-block:: console\n\n $ poetry add pomcorn\n\n*******************************************************************************\nDocumentation\n*******************************************************************************\n\nLink to the documentation: http://pomcorn.rtfd.io/.\n\n*******************************************************************************\nUsage\n*******************************************************************************\n\nYou need to\n`install pomcorn <https://pomcorn.readthedocs.io/en/latest/installation.html>`_ and\n`Chrome webdriver <https://pomcorn.readthedocs.io/en/latest/installation.html#chrome-driver>`_.\n\nBelow is the code that opens ``PyPI.org``, searches for packages by name and prints names of found\npackages to the terminal. The script contains all base classes contained in ``pomcorn``: **Page**,\n**ComponentWithBaseLocator**, **ListComponent** and **Element**.\n\n.. code-block:: python\n\n from typing import Self\n\n from selenium.webdriver import Chrome\n from selenium.webdriver.common.keys import Keys\n from selenium.webdriver.remote.webdriver import WebDriver\n\n from pomcorn import ComponentWithBaseLocator, Element, ListComponent, Page, locators\n\n\n # Prepare base page\n class PyPIPage(Page):\n\n APP_ROOT = \"https://pypi.org\"\n\n def check_page_is_loaded(self) -> bool:\n return self.init_element(locators.TagNameLocator(\"main\")).is_displayed\n\n @property\n def search(self) -> Element[locators.XPathLocator]:\n return self.init_element(locators.IdLocator(\"search\"))\n\n\n # Prepare components\n Package = ComponentWithBaseLocator[PyPIPage]\n\n\n class PackageList(ListComponent[Package, PyPIPage]):\n\n item_class = Package\n\n @property\n def base_item_locator(self) -> locators.XPathLocator:\n return self.base_locator // locators.ClassLocator(\"snippet__name\")\n\n @property\n def names(self) -> list[str]:\n return [package.body.get_text() for package in self.all]\n\n\n # Prepare search page\n class SearchPage(PyPIPage):\n\n @classmethod\n def open(cls, webdriver: WebDriver, **kwargs) -> Self:\n pypi_page = super().open(webdriver, **kwargs)\n # Specific logic for PyPI for an open search page\n pypi_page.search.fill(\"\")\n pypi_page.search.send_keys(Keys.ENTER)\n return cls(webdriver, **kwargs)\n\n @property\n def results(self) -> PackageList:\n return PackageList(\n page=self,\n base_locator=locators.PropertyLocator(\n prop=\"aria-label\",\n value=\"Search results\",\n ),\n )\n\n def find(self, query: str) -> PackageList:\n self.search.fill(query)\n self.search.send_keys(Keys.ENTER)\n return self.results\n\n\n search_page = SearchPage.open(webdriver=Chrome())\n print(search_page.find(\"saritasa\").names)\n\nFor more information about package classes, you can read in `Object Hierarchy <https://pomcorn.readthedocs.io/en/latest/objects_hierarchy.html>`_\nand `Developer Interface <https://pomcorn.readthedocs.io/en/latest/developer_interface.html>`_.\n\nAlso you can try our `demo autotests project <https://pomcorn.readthedocs.io/en/latest/demo.html>`_.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Base implementation of Page Object Model",
"version": "0.6.0",
"project_urls": {
"Documentation": "http://pomcorn.rtfd.io/",
"Homepage": "https://pypi.org/project/pomcorn/",
"Repository": "https://github.com/saritasa-nest/pomcorn/"
},
"split_keywords": [
"python",
" selenium",
" webdriver",
" autotests",
" page object model",
" page object pattern",
" page object",
" pom",
" parsing",
" browser"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "db17b9cbd05fc2fae6586131a52360954457ade12b2d1286873772b85443c1bb",
"md5": "9942727ecc33739b015b4eced337429e",
"sha256": "53ea4cb40cd665377d1558870c910944da9ae396c30f027e302e205ecb5b9033"
},
"downloads": -1,
"filename": "pomcorn-0.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9942727ecc33739b015b4eced337429e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 18828,
"upload_time": "2024-04-17T05:52:36",
"upload_time_iso_8601": "2024-04-17T05:52:36.160530Z",
"url": "https://files.pythonhosted.org/packages/db/17/b9cbd05fc2fae6586131a52360954457ade12b2d1286873772b85443c1bb/pomcorn-0.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c98364bcfb9027425f5ce1edd93ae9353c2ebdf2a0041a6513bae1e74ab63391",
"md5": "ea7c4d7420625f94b5f2d8ab075d92f9",
"sha256": "ce7b1e47eb025f1cb6c7db1b76ed2cbc7bc2ab56bf9c14afa05ca9f543af3cb7"
},
"downloads": -1,
"filename": "pomcorn-0.6.0.tar.gz",
"has_sig": false,
"md5_digest": "ea7c4d7420625f94b5f2d8ab075d92f9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 18306,
"upload_time": "2024-04-17T05:52:40",
"upload_time_iso_8601": "2024-04-17T05:52:40.077003Z",
"url": "https://files.pythonhosted.org/packages/c9/83/64bcfb9027425f5ce1edd93ae9353c2ebdf2a0041a6513bae1e74ab63391/pomcorn-0.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-17 05:52:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "saritasa-nest",
"github_project": "pomcorn",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pomcorn"
}