A simple UI automation framework built with:
- Python: 3.9 - 3.12
- pytest: 8.3.0
- Selenium: 4.24.0
- CI: GitHub Actions
- User-friendly UI automation framework.
- Built on popular Python libraries: pytest and Selenium.
- Supports Chrome, Firefox, and Remote browsers for UI testing.
- Utilities for setting up and managing WebDriver instances.
- Integrated with GitHub Actions CI workflow for Darwin (Mac) and Linux.
- Supports multiple environments: dev, stage.
- Generates pytest reports and custom logs.
- Secure Secrets Handling: Sensitive data like passwords are encrypted and stored securely.
- Test Data Management: Integrated with YAML files for test data storage and access.
- Python 3.8 - 3.12
- If you're not using macOS with ARM64 architecture or a Selenium version below 4.24.0, please upload the appropriate driver corresponding to your OS to the
resources
directory. - secure-test-automation for encrypting sensitive data
-
Clone this repository:
git clone <repository-url>
-
Install required dependencies:
pip install poetry poetry shell poetry install
-
Create a
.env
file and add:DEV_URL = "your-dev-project-url" STAG_URL = "your-staging-project-url"
- Rename the
chromedriver
tolocal
if you want to run tests locally.
- Rename the
-
If you prefer not to use environment variables, add your references to the properties file:
class Properties: _ENV_VARIABLES = { "dev": ("DEV_URL", ""), "stag": ("STAG_URL", ""), # Add more environments and their default URLs as needed }
- You can download the latest version of the driver for macOS ARM64 using the
chromedriver.sh
script located in theresources
folder.
- When running CI locally, ensure your Git resources contain the correct Chrome driver with x86_64 architecture (unless using Selenium version 4.24.0 or higher).
- Go to Repository Settings -> Secrets and Variables -> Actions -> Variables, and add
DEV_URL
,STAG_URL
. - CI configuration is available for running tests on Ubuntu in
run_test_ubuntu.yaml
. -
jobs: selenium-tests: runs-on: macos-latest env: DEV_URL: ${{ vars.DEV_URL }} STAG_URL: ${{ vars.STAG_URL }}
The linting configuration defines rules that dictate the checks performed. Customize these rules to suit your project's coding style and requirements.
- Create external tools to run linting.
- Set the working directory to:
$ProjectFileDir$
- Specify the program:
path to your ruff installed /bin/ruff
- Provide the arguments:
$FilePathRelativeToProjectRoot$ --config .ruff.toml
To secure our passwords or sensitive data, we store them in an encrypted form. For this, we use the secure-test-automation library.
implementation on framework side: utils/crypto.py
Pay attention The encryption key is stored in /config/key.properties
(this file should be added to .gitignore
) for local testing.
For executing tests in remote environments (e.g., BrowserStack, Jenkins, etc.), we have integrated the Vault HashiCorp library.
@pytest.fixture
def get_password():
secure = Secure()
read = YAMLReader.read("data.yaml", to_simple_namespace=True)
password = read.users.john.details.password
return secure.decrypt_password(password)