Skip to main content

Pomcorn

GitHub last commit GitHub Workflow Status (with event) PyPI PyPI - Status PyPI - Python Version PyPI - License PyPI - Downloads Ruff prek

Check out our other open-source projects

Pomcorn, or Page Object Model corn, is a Python package that contains base classes to create systems based on Selenium framework and Page Object Model pattern. You can read more about this pattern. 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:

  classDiagram
    WebView <|-- Component
    WebView <|-- Page
    Component <|-- ListComponent
    Component .. Locator
    Page .. Component

    class WebView{
        -webdriver: Webdriver
    }
    class Page{
        +wait_until_loaded()
        +open()
    }
    class Component{
        -page: Page
        -base_locator: Locator
        + wait_until_visible()
    }
    class ListComponent{
        -item_locator: Locator
        +count()
        +all()
        +get_item_by_text()
    }
    class Locator{
      -query: String
    }

It also includes classes to locate elements on the web page and a number of additional waiting conditions.

Installation

You can install it by pip:

  pip install pomcorn

Or poetry:

  poetry add pomcorn

Documentation

Link to the documentation: https://saritasa-nest.github.io/pomcorn/latest/.

Usage

Install pomcorn using installation guide.

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, Component, ListComponent and Element.

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 Component, Element, ListComponent, Page, locators


# Prepare base page
class PyPIPage(Page):
    APP_ROOT = "https://pypi.org"

    search = Element(locators.IdLocator("search"))

    def check_page_is_loaded(self) -> bool:
        return self.init_element(locators.TagNameLocator("main")).is_displayed


# Prepare components
Package = Component[PyPIPage]


class PackageList(ListComponent[Package, PyPIPage]):
    relative_item_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)
search_page.webdriver.close()

For more information about package classes, you can read in Object Hierarchy and Developer Interface.

Also you can try our demo autotests project.

Metadata

Release files for pomcorn 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pomcorn 0.12.0
File Size Uploaded Provenance Actions
pomcorn-0.12.0.tar.gz 399.5 kB Without provenance Details for pomcorn-0.12.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pomcorn 0.12.0
File Interpreter ABI Platform Actions
pomcorn-0.12.0-py3-none-any.whl Python 3 none any Details for pomcorn-0.12.0-py3-none-any.whl

Total release size: 423.8 kB

Release files / pomcorn-0.12.0.tar.gz

Download URL pomcorn-0.12.0.tar.gz
Size 399.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a6b65bd2cb38d2220c816faffcc889a25df6a596722310e2acf520fc2bc483d4
BLAKE2b-256 checksum
How to use checksums
93cc56804b19342571dfdf6abffbdd002f47f195bcc90ad7717c227e3e1eeee9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pomcorn-0.12.0-py3-none-any.whl

Download URL pomcorn-0.12.0-py3-none-any.whl
Size 24.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa10737d1da3dbfc70c9b5d2473891fbfdba8a805a605be4892a434c8cf901b0
BLAKE2b-256 checksum
How to use checksums
b88ea6a5ab4fe543f95963ea89b375eae0946ecdf5f2947d740888bd11aaed3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for pomcorn 0.12.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page