Skip to main content

Annotation

POM is Page-Object-Model microframework to develop web UI tests easy, quickly and with pleasure.

Architecture

POM provides API to manipulate with web UI elements and pages in browser. Under hood it uses selenium. Before to act with UI element POM waits for its visibility, because in user cases user can’t interact with UI element if it isn’t visible at display. POM provides tree hirarchy to request UI elements with UI caching mechanism at each level.

POM doesn’t use implicit_wait method to wait UI element, because implicit_wait waits until element is present at DOM even if it isn’t visible. And also implicit_wait has conflict with caching mechanism, that leads to long requests in some cases.

So POM has own implementation to wait element before interact. It leads to additinal webdriver request before interact with UI element, but provide reliable and simple architecture, without speed degradation.

How to start

Let imagine simple testcase:

  • Go to https://facebook.com

  • Fill login / password fields with 'admin' / 'admin' values

  • Click button login

  • Assert page to log in is opened

  • Assert alert message is opened

Its implementation with POM:

import unittest

import pom
from pom import ui
from selenium.webdriver.common.by import By


@ui.register_ui(field_login=ui.TextField(By.NAME, 'email'),
                field_password=ui.TextField(By.NAME, 'pass'))
class FormLogin(ui.Form):
    """Form to login."""


@ui.register_ui(form_login=FormLogin(By.ID, 'login_form'))
class PageMain(pom.Page):
    """Main page."""
    url = '/'


@ui.register_ui(
    alert_message=ui.Block(By.CSS_SELECTOR, 'div.uiContextualLayerPositioner'))
class PageLogin(pom.Page):
    """Login page."""
    url = '/login'


@pom.register_pages([PageMain, PageLogin])
class Facebook(pom.App):
    """Facebook web application."""
    def __init__(self):
        super(Facebook, self).__init__('https://www.facebook.com', 'firefox')
        self.webdriver.maximize_window()
        self.webdriver.set_page_load_timeout(30)


class TestCase(unittest.TestCase):

    def setUp(self):
        self.fb = Facebook()
        self.addCleanup(self.fb.quit)

    def test_facebook_invalid_login(self):
        """User with invalid credentials can't login to facebook."""
        self.fb.page_main.open()
        with self.fb.page_main.form_login as form:
            form.field_login.value = 'admin'
            form.field_password.value = 'admin'
            form.submit()
        assert self.fb.current_page == self.fb.page_login
        assert self.fb.page_login.alert_message.is_present

To launch example:

  • Save example code in file test_pom.py

  • Install POM framework pip install python-pom

  • Launch test example python -m unittest test_pom

Full example of usage is in https://github.com/sergeychipiga/horizon_autotests.

Supported UI components

In progress…

Metadata

Release files for python-pom 1.0.7

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

Source distribution (sdist)

Source distribution for python-pom 1.0.7
File Size Uploaded Provenance
python-pom-1.0.7.tar.gz 8.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for python-pom 1.0.7
File Interpreter ABI Platform
python_pom-1.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 22.8 kB

Release files / python-pom-1.0.7.tar.gz

Download URL python-pom-1.0.7.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1817331a44dd43d0dde36cdb1005e6bb2404612da05b0f9da2e8ece7c66eb255
BLAKE2b-256 checksum
How to use checksums
5af9a3dd3a37adece0ea3a712b06bf1cc12aeed7f7bc2aa4e425c96d1877aa3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.2

Release files / python_pom-1.0.7-py3-none-any.whl

Download URL python_pom-1.0.7-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84da66be6776b40a77c801eaf74f889bff68c147d70d5397980f8cc419acbbec
BLAKE2b-256 checksum
How to use checksums
90091f9e81db101ea8dfb83a88536a2cb60706664ca05708809b0a2517b76c7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.2

Security for python-pom 1.0.7

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.

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