Skip to main content

Selenium wrapper for testing Web UI

Project description

https://gitlab.uaprom/uaprom/promium/badges/master/pipeline.svg https://gitlab.uaprom/uaprom/promium/badges/master/coverage.svg https://img.shields.io/badge/python-2.7%2C%203.5%2C%203.6-blue.svg https://badge.fury.io/py/Promium.svg

Simple selenium wrapper from implemented UI tests

Watch documentation

Quick Start

Install

Promium

pip install promium

Selenium

pip install selenium

Driver

# get actual chrome driver version
CHROME_DRIVER_VERSION=$(wget http://chromedriver.storage.googleapis.com/LATEST_RELEASE -q -O -)

# download chrome driver
wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip

# unpack
unzip /tmp/chromedriver_linux64.zip -d /opt/selenium

# add link from chrome driver
ln -fs /opt/selenium/chromedriver /usr/bin/chromedriver

Examples

Page Objects

from selenium.webdriver.common.by import By

from promium import Page, Block, Element, InputField, Link


class ResultBlock(Block):

    title = Link(By.CSS_SELECTOR, 'h3')
    link = Element(By.CSS_SELECTOR, '.f')
    description = Element(By.CSS_SELECTOR, '.st')
    tags = Element.as_list(By.CSS_SELECTOR, '.osl .fl')


class GoogleResultPage(Page):

    results_blocks = ResultBlock.as_list(By.CSS_SELECTOR, '#rso .srg div.g')


class GoogleMainPage(Page):

    url = 'https://google.com'
    logo = Element(By.CSS_SELECTOR, '#hplogo')
    search_input = InputField(By.CSS_SELECTOR, '[name="q"]')

    def search(self, text):
        self.search_input.send_keys(text)
        self.search_input.submit()
        return GoogleResultPage(self.driver)

Simple test from google page

from promium.test_case import WebDriverTestCase

from tests.pages.google_page import GoogleMainPage


class TestMainGooglePage(WebDriverTestCase):

    def test_search(self):
        main_page = GoogleMainPage(self.driver)
        main_page.open()
        self.soft_assert_element_is_displayed(main_page.logo)
        result_page = main_page.search('Selenium')
        result_block = result_page.results_blocks.first_item
        self.soft_assert_in('Selenium', result_block.title.text)

Run test

# all tests
pytest tests/

# all tests in suite
pytest tests/test_google.py

# only one test
pytest tests/test_google.py -k test_search

Project details


Release history Release notifications | RSS feed

This version

1.2.7

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Promium-1.2.7.tar.gz (41.5 kB view details)

Uploaded Source

File details

Details for the file Promium-1.2.7.tar.gz.

File metadata

  • Download URL: Promium-1.2.7.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for Promium-1.2.7.tar.gz
Algorithm Hash digest
SHA256 8e9c75b67c6371d5e9083f43bc7a6188c172b2a22419583acdb72be1438024df
MD5 0a8e82b707fe8e9e7d120ff38aae4e29
BLAKE2b-256 7dae594bbe1938f3d90f16544b6c6ef55aac4a5305f1c9a3cd4ab89453f7cea8

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page