Selenium wrapper for testing Web UI
Project description
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
Develop
Build docker image:
docker build --cache-from registry.evo.dev/qa-automation/promium/base-env:latest -f docker/Dockerfile -t registry.evo.dev/qa-automation/promium/base-env:latest .
check lint:
docker-compose run flake8
run selenium(ui) test:
docker-compose run test-se -n 8
run request test:
docker-compose run test-requests -n 8
run unit test:
docker-compose run test-unit -n 8
Build documentation:
docker-compose run doc
Run test into container:
docker run -e SE_DRIVER=http+chrome://static-selenium-hub.qa-automation.stg.evo/wd/hub -e HEADLESS=Enabled --net=host -it registry.evo.dev/qa-automation/promium/base-env:latest pytest -p no:warnings -p no:cacheprovider -v -m se -n 4
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Promium-3.1.0.tar.gz
(43.3 kB
view details)
File details
Details for the file Promium-3.1.0.tar.gz
.
File metadata
- Download URL: Promium-3.1.0.tar.gz
- Upload date:
- Size: 43.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a5d1ca7549d89bb27661319a93c7333a74f0d333855f3cb3904f91bdb6a4a46 |
|
MD5 | a306c6a4206bfe20be5a00e7e2929df3 |
|
BLAKE2b-256 | 7523ae457466ea4c6360c7b4a61d653cc73a9bd221c0d826c0555a89268b8108 |