Automation framework for the WebDriver API
Project description
PAF - Python Automation Framework
Python implementation of Testerra API.
It is basically a wrapper for Selenium WebDriver and WebElement which bring some more comfort features. This is not a test framework, but it implements some assertion features anyway.
The basic concept is, to identify WebElements on every action or property accessor to prevent StaleElementExceptions
.
Quick start
import inject
import paf.config
from paf.locator import By
from paf.page import FinderPage, PageFactory
# Configure dependency injection
inject.configure(paf.config.inject)
# Instantiate the page factory
page_factory = inject.instance(PageFactory)
# Create a simple finder page
page = page_factory.create_page(FinderPage)
# Visit URL
page.open("https://google.com")
# Find element
element = page.find("#q")
# Perform actions
element.type("Search")
# Perform assertions
element.expect.text.be("Search")
Prerequisites
-
You need at least a local WebDriver installed.
brew|choco|apt install chromedriver
-
Python 3.10 (or higher).
Feature list
Missing features (todos)
- Rect assertions
- ShadowRoot support
- Drag & Drop over frames
Environment variables
PAF_BROWSER_SETTING=chrome:90
: Sets the requested browser name and it's version.PAF_WINDOW_SIZE=1920x1080
: Sets the browsers default window size.PAF_SCREENSHOTS_DIR=screenshots
: Sets the screenshots' directory.PAF_SEQUENCE_WAIT_AFTER_FAIL=0.3
: Wait in seconds whenever a sequence action fails.PAF_SEQUENCE_RETRY_COUNT=3
: Retry count for every sequence action.
Examples
I added two examples.
- test_google.py: is a regular Google search, implemented with Page Objects and Components.
- test_todo_mvc.py: are re-implemented test cases from the Robot Framework TodoMVC example. It's IMHO developer friendly, better readable and less code.
Developer area
Run the tests
PYTHONPATH="." pytest --numprocesses=4 --cov=paf test
Utils
xpath = "//dt[.//text()='Title:']/following-sibling::dd[1]"
snapshot = document.evaluate(xpath, document.body, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE)
snapshot.snapshotItem(0).textContent
Release update
- Update version in
setup.py
- Package library
python setup.py sdist
- Publish library
twine upload dist/python-automation-framework-[version].tar.gz
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
Close
Hashes for python-automation-framework-0.0.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8af1fa18439e2b5c55638a7d2bcd202b2a737cb6205aab2efe453047c77a82a |
|
MD5 | c39660e2c84fb1d252d72cb1686d6342 |
|
BLAKE2b-256 | d0fc64c99cee65ed4bf70fa43b8a75f472158dc4a69520fd03c583864fd3ae1a |