Skip to main content

Github-flavored Markdown

PySelPOM

PySelPOM is a Page Object Model selenium based framework for humans. It allows you to write your own web test with no need to look under the framework hood in most cases.

Installation

For most users, the recommended method to install is via pip:

pip install pyselpom

or from source:

python setup.py install

Conftest content

import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options


def pytest_addoption(parser):
    parser.addoption('--language', action='store', default='en', help='Specify language param.')
    parser.addoption('--browser_name', action='store', default='chrome', help='Choose browser: chrome or firefox')


@pytest.fixture
def driver(request) -> webdriver:
    user_language = request.config.getoption('language')
    browser_name = request.config.getoption('browser_name')

    if browser_name == 'chrome':
        print('\nStart chrome browser for test...')
        options = Options()
        # noinspection PyTypeChecker
        options.add_experimental_option('prefs', {'intl.accept_languages': user_language})
        browser = webdriver.Chrome(options=options)
    elif browser_name == 'firefox':
        print('\nStart firefox browser for test...')
        fp = webdriver.FirefoxProfile()
        fp.set_preference('intl.accept_languages', user_language)
        browser = webdriver.Firefox(firefox_profile=fp)
    else:
        raise pytest.UsageError('--browser_name should be chrome or firefox')

    yield browser

    browser.quit()

Page example

from pyselpom import BasePage


class MainPage(BasePage):
    URL_PATTERN = 'https://google.com/'


class LoginPage(BasePage):
    link = 'https://google.com/login/'

    def should_be_login_page(self):
        self.should_be_login_url()
        self.should_be_login_form()
        self.should_be_register_form()

    def should_be_login_url(self):
        assert 'login' in self.browser.current_url

    def should_be_login_form(self):
        assert self.is_element_present(*LoginPageLocators.LOGIN_FORM), 'Login form does not exist.'

    def should_be_register_form(self):
        assert self.is_element_present(*LoginPageLocators.REGISTER_FORM), 'Register form does not exist.'

    def register_new_user(self, email, password):
        self.browser.find_element(*LoginPageLocators.REGISTER_MAIL).send_keys(email)
        self.browser.find_element(*LoginPageLocators.REGISTER_PASSWORD).send_keys(password)
        self.browser.find_element(*LoginPageLocators.REGISTER_PASSWORD_CONFIRM).send_keys(password)
        self.browser.find_element(*LoginPageLocators.REGISTER).click()

Locators

from selenium.webdriver.common.by import By


class LoginPageLocators:
    LOGIN_FORM = (By.ID, 'login_form')
    REGISTER_FORM = (By.ID, 'register_form')
    REGISTER_MAIL = (By.NAME, 'registration-email')
    REGISTER_PASSWORD = (By.NAME, 'registration-password1')
    REGISTER_PASSWORD_CONFIRM = (By.NAME, 'registration-password2')
    REGISTER = (By.NAME, 'registration_submit')

Test example

import pytest

from .pages.login_page import LoginPage
from .pages.main_page import MainPage


@pytest.mark.login_guest
class TestLoginFromMainPage:
    def test_guest_can_go_to_login_page(self, browser):
        page = MainPage(browser, MainPage.link)
        page.open()
        page.go_to_login_page()
        login_page = LoginPage(browser, browser.current_url)
        login_page.should_be_login_page()

Changelog

1.2.3 (2-03-2022)

  • .is_ returns bool now

Metadata

Release files for pyselpom 1.2.3

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

Source distribution (sdist)

Source distribution for pyselpom 1.2.3
File Size Uploaded Provenance Actions
pyselpom-1.2.3.tar.gz 9.1 kB Without provenance Details for pyselpom-1.2.3.tar.gz

Built distribution (wheel)

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

Total release size: 21.6 kB

Release files / pyselpom-1.2.3.tar.gz

Download URL pyselpom-1.2.3.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9659e0de54b5ff97ea08a162247b42ebc147c0c98fd3b34516c6a306ea733e2d
BLAKE2b-256 checksum
How to use checksums
cd32f2cd7c4dae5684d0782c32442ac42ef894d98148622dd6f07d38d4ae4438
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.0

Release files / pyselpom-1.2.3-py3-none-any.whl

Download URL pyselpom-1.2.3-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e97e2afb4c625d1bfac9d28a3d9ea37060e8b2844a967251c8553ce2a6b4736
BLAKE2b-256 checksum
How to use checksums
f8e7460b51ad757d5058d5f78e4fc259e235e7336ce1029062ffe562223c45eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.0

Security for pyselpom 1.2.3

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