UiTestCore
This package helps with writing UI tests by providing a wrapper around Selenium and other useful functions. UiTestCore was designed with Page Object Model in mind, and makes it easy to create an acceptance test pack without the need to write any Selenium code.
The repository for this project can be found on GitHub: https://github.com/nhsuk/ui-test-core
Example
The below example shows how you can create a class representing a web page, in this case a login page.
from uitestcore.page import BasePage
from uitestcore.page_element import PageElement
from selenium.webdriver.common.by import By
class MyLoginPage(BasePage):
# Define elements to interact with
header_logo = PageElement(By.ID, "company-logo")
username_field = PageElement(By.ID, "input-user")
password_field = PageElement(By.CLASS_NAME, "field-password")
login_button = PageElement(By.XPATH, "//button[text()='Login']")
def open_login_page(self):
self.interact.open_url("https://mysite.com/login")
self.wait.for_page_to_load()
def logo_visible(self):
return self.interrogate.is_element_visible(self.header_logo)
def enter_username(self, username):
self.interact.enter_text(self.username_field, username)
def enter_password(self, password):
self.interact.enter_text(self.password_field, password)
def click_login_button(self):
self.interact.click_element(self.login_button)
The "BasePage" class is provided so that any page classes in the test pack can inherit from it, giving access to many useful functions which are separated into "find", "interrogate", "interact" and "wait". The "PageElement" class is used to define any elements which your tests need to interact with, so they can be reused without needing to remember whether you're looking for a class, ID etc (all Selenium selector types are supported).
The above page class could then be used in the test steps to perform any required actions and assertions.
You must supply a selenium.webdriver driver object when instantiating the page
login_page = MyLoginPage(driver)
login_page.open_login_page()
Installation
This package is located on PyPI: https://pypi.org/project/uitestcore/ - it can be installed in the usual way i.e. pip install uitestcore
The easiest way to include this package in your project is by adding it to your requirements.txt. Here is an example of the line which should be added to this file, we recommend using a specific version but it's your call:
uitestcore==10.4.0
Using 10.4.0 in Linux and with Chromium
Please note, that due to a change in Selenium manager between versions 4.10 and 4.11.2, it is now necessary to set a local environment variable which points to the browser installation location. Failure to do so will result in the browser failing to initialise when running your tests. This is caused by Selenium Manager expecting a 'Chrome' installation; it does not currently fall back to check for Chromium.
Set:
ENV SE_BROWSER_PATH=/usr/bin/chromium-browser
Deployment to PyPI
PyPI deployment is configured in the release pipeline of the NHS.UK Azure Devops project. Any changes merged into master will be automatically deployed to PyPI, and any changes pushed to a branch starting with "test/" will be automatically deployed to TestPyPI.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Dependencies
The package dependencies along with links to their licenses are as follows:
certifi - http://mozilla.org/MPL/2.0/
chardet - https://github.com/chardet/chardet/blob/master/LICENSE
idna - https://github.com/kjd/idna/blob/master/LICENSE.rst
pyhamcrest - https://github.com/hamcrest/PyHamcrest/blob/master/LICENSE.txt
python-dateutil - https://github.com/pganssle/dateutil/blob/master/LICENSE
requests - https://github.com/psf/requests/blob/master/LICENSE
selenium - https://github.com/SeleniumHQ/selenium/blob/master/LICENSE
six - https://github.com/benjaminp/six/blob/master/LICENSE
urllib3 - https://github.com/urllib3/urllib3/blob/master/LICENSE.txt
Contribute
Read our contributing guidelines to contribute to UiTestCore.
Metadata
Release files for uitestcore 10.6.1
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 |
|---|---|---|---|---|
| uitestcore-10.6.1.tar.gz | 37.9 kB | Without provenance | Details for uitestcore-10.6.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| uitestcore-10.6.1-py3-none-any.whl | Python 3 | none | any | Details for uitestcore-10.6.1-py3-none-any.whl |
Total release size: 83.6 kB
Release files / uitestcore-10.6.1.tar.gz
| Download URL | uitestcore-10.6.1.tar.gz |
|---|---|
| Size | 37.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f41dd84a56f275047ea2c9d3eea79ff503fdc17ee3a6566ba95aa2f1851d5f5
|
|
BLAKE2b-256 checksum How to use checksums |
f1bcc8e1a4f0f1d4c277be4afe99ab003eb876e25325e0f53c87b7c81c9223c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / uitestcore-10.6.1-py3-none-any.whl
| Download URL | uitestcore-10.6.1-py3-none-any.whl |
|---|---|
| Size | 45.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2509c44a6bd7cedd094e2d772b5ee6f7d8f0f61f8108728000f725da592ca67c
|
|
BLAKE2b-256 checksum How to use checksums |
7f316dd87559721e7b1a6366691c043ef6cc6015c326403947013407b6c11fc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for uitestcore 10.6.1
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.