Skip to main content

Package providing common functionality for UI automation test packs

Project description

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==3.3.0

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.

Project details


Download files

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

Source Distribution

uitestcore-7.0.2.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

uitestcore-7.0.2-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file uitestcore-7.0.2.tar.gz.

File metadata

  • Download URL: uitestcore-7.0.2.tar.gz
  • Upload date:
  • Size: 17.8 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.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for uitestcore-7.0.2.tar.gz
Algorithm Hash digest
SHA256 5d88a26f57c84d4c8af5dad628001f6bd642fb98a62a0a1d74792f3046071b6e
MD5 f02d536644e259101715914e604350d5
BLAKE2b-256 eb1a661e69e94f7432c4ac21e9a3abcd7c31451c712054c06945bbc88b76fff4

See more details on using hashes here.

Provenance

File details

Details for the file uitestcore-7.0.2-py3-none-any.whl.

File metadata

  • Download URL: uitestcore-7.0.2-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for uitestcore-7.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 34f02024c4381262f2ced173b95eaec54a4179b77c1fcce47c9bfea4e377112f
MD5 196250d7d9471b35fb8c516789231acc
BLAKE2b-256 13a572ddd6c235120296423abebb4bad163679f50dfa072758dd10e89af4058d

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