Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sample framework with python, selenium and pytest, using CI GitHub Actions and Poetry

License

NotificationsYou must be signed in to change notification settings

dmberezovskyii/pytest-python-selenium-framework

Repository files navigation

A simple UI automation framework built with:

  • Python: 3.9 - 3.12
  • pytest: 8.3.0
  • Selenium: 4.24.0
  • CI: GitHub Actions

LinkedIn

Features

  • User-friendly UI automation framework.
  • Built on popular Python libraries: pytest and Selenium.
  • SupportsChrome,Firefox, andRemote browsers for UI testing.
  • Utilities for setting up and managing WebDriver instances.
  • Integrated withGitHub Actions CI workflow for Darwin (Mac) and Linux.
  • Supports multiple environments:dev,stage.
  • Generatespytest reports andcustom 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.

Getting Started

Prerequisites

  • 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 theresources directory.

Local Usage

  1. Clone this repository:

    git clone<repository-url>
  2. Install required dependencies:

    pip install poetrypoetry shellpoetry env infocopy`Executable: path to virtual env` -> Add Interpreter -> Poetry Environment -> Existing environment -> add Executable -> Applypoetry install

    then specify your poetry env

  3. Create a.env file and add:

    DEV_URL = "your-dev-project-url"STAG_URL = "your-staging-project-url"
  4. If you prefer not to use environment variables, add your references to the properties file:

    classProperties:_ENV_VARIABLES= {"dev": ("DEV_URL",""),"stag": ("STAG_URL",""),# Add more environments and their default URLs as needed    }

Latest Drivers

CI: GitHub Actions

Important Notes

  • 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 toRepository Settings ->Secrets and Variables ->Actions ->Variables, and addDEV_URL,STAG_URL.
  • CI configuration is available for running tests on Ubuntu inrun_test_ubuntu.yaml.
  •  jobs:    selenium-tests:      runs-on: macos-latest      env:        DEV_URL: ${{ vars.DEV_URL }}        STAG_URL: ${{ vars.STAG_URL }}

Local: Ruff Lint Configuration

The linting configuration defines rules that dictate the checks performed. Customize these rules to suit your project's coding style and requirements.

  1. Create external tools to run linting.
  2. Set the working directory to:
    $ProjectFileDir$
  3. Specify the program:
    path to your ruff installed /bin/ruff
  4. Provide the arguments:
    $FilePathRelativeToProjectRoot$ --config .ruff.toml

Secrets

To secure our passwords or sensitive data, we store them in an encrypted form. For this, we use thesecure-test-automation library.implementation on framework side: utils/crypto.pyPay 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.fixturedefget_password():secure=Secure()read=YAMLReader.read("data.yaml",to_simple_namespace=True)password=read.users.john.details.passwordreturnsecure.decrypt_password(password)

[8]ページ先頭

©2009-2025 Movatter.jp