UI Test Framework
Package for Testing Browser User interfaces.
Installation
pip install uitestframework
You must also download the driver for your selected browser and place it in your working directory Drivers can be downloaded here.
Usage
The UI Test Framework provides a base for creating browser based UI tests by using the Page Object Model and selenium webdriver. You might find it most useful for testing web application in development in which the UI is continually being changed. Typical usage often looks like this:
from unittest import TestCase
from uitestframework import UITestCaseMixin, PageObjectModel
from uitestframework.pom import BasePage, BaseElement
APPLICATION_HOST = "https://localhost:8080"
class MyPage(BasePage):
def set_elements(self):
# adds a BaseElement instance "Button1" to MyPage
button1 = BaseElement(name="Button1", locator="button_id", locator_type='id', page=self)
return [button1]
class MyPOM(PageObjectModel):
# Maps url paths to BasePage instance
url_map = {
'': MyPage,
}
class MyTestCase(UITestCaseMixin, TestCase):
# These are necessary attributes for this class
driver_path = "chromedriver.exe"
browser = 'chrome'
pom = MyPOM()
def test_foo(self):
# tests that button 1 redirects you from the current page
self.driver.get(APPLICATION_HOST)
# Using the url map, the pom knows in which page to look for the specified element attribute
# Several methods for interacting with UI are implemented in the BaseElement class and its Subclasses
self.pom.button1.click()
self.assertTrue(self.driver.current_url != APPLICATION_HOST)
To test pages which require user input. The FormPage class can be used. An example of usage is provided below::
#!/usr/bin/env python
from unittest import TestCase
from selenium.webdriver.common.by import By
from uitestframework import UITestCaseMixin, PageObjectModel
from uitestframework.pom import FormPage, FieldElement, BaseElement
APPLICATION_HOST = "https://localhost:8080"
class LoginPage(FormPage):
def set_elements(self):
username = FieldElement(name='username', locator="id_username", locator_type=By.ID, page=self)
password = FieldElement(name='password', locator="id_password", locator_type=By.ID, page=self)
submit = FieldElement(name='submit', locator="id_submit", locator_type=By.ID, page=self)
error_message = BaseElement(name='error_message', locator="id_error", locator_type=By.ID, page=self)
return [username, password, submit, error_message]
class MyApplicationPOM(PageObjectModel):
url_map = {
'/login': LoginPage,
}
class MyTestCase(UITestCaseMixin, TestCase):
driver_path = "chromedriver.exe"
browser = 'chrome'
pom = MyApplicationPOM()
def test_login(self):
login_url = APPLICATION_HOST + '/login'
self.driver.get(login_url)
self.pom.autofill(username='username', password='correct password')
self.pom.submit.click()
self.assertTrue(self.driver.current_url != login_url)
def test_failed_login(self):
login_url = APPLICATION_HOST + '/login'
self.driver.get(login_url)
self.pom.autofill(username='username', password='wrong password')
self.pom.submit.click()
self.assertTrue(self.pom.error_message.is_rendered())
Metadata
Release files for uitestframework 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| uitestframework-0.0.2.tar.gz | 4.9 kB | Without provenance | Details for uitestframework-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| uitestframework-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for uitestframework-0.0.2-py3-none-any.whl |
Total release size: 11.2 kB
Release files / uitestframework-0.0.2.tar.gz
| Download URL | uitestframework-0.0.2.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc017fc37700b1324828cb52b44c7c8e80ad020c554e5a9fc9a677ba2473e277
|
|
BLAKE2b-256 checksum How to use checksums |
9b36218fc2ae7049b5683f53672efff95239476000a5f3916e924ecd2b284487
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
|
Release files / uitestframework-0.0.2-py3-none-any.whl
| Download URL | uitestframework-0.0.2-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
142107111d5af344f03d2f493fd30dd2e18c0a3b3c23f6eb0b5cebd3b5353c59
|
|
BLAKE2b-256 checksum How to use checksums |
a6f4f4dbe4f036ef5de0f06257d5c032230ac294271c1b8d337014e03c8569db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
|
Security for uitestframework 0.0.2
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.