Skip to content

nirtal85/Selenium-Python-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Selenium Python Example

twitter dev run nightly Imports: isort Code style: black

๐Ÿ“ƒ Articles written about this project

๐Ÿ› ๏ธ Tech Stack

Tool Description
allure-pytest Allure reporting with your Pytest tests for better reporting
assertpy An expressive assertion library for Python
dataclasses-json A library for serialization of dataclasses to and from JSON
deprecated A library for emitting warnings about deprecated code
mailinator-python-client-2 A Python client for interacting with the Mailinator email service
mysql-connector-python Interface for connecting to MySQL databases and executing SQL queries
pytest A popular testing framework for Python
pytest-base-url Pytest plugin for setting a base URL for your tests
pytest-check Provides additional checking functionality for your Pytest tests
pytest-dependency Pytest plugin that allows declaring dependencies between tests
pytest-ordering Pytest plugin for ordering test functions
pytest-rerunfailures Pytest plugin to rerun failed tests automatically
python-dotenv Loads environment variables from a .env file, simplifying configuration
requests A versatile library for making HTTP requests in Python
requests-toolbelt Collection of utilities for python-requests
selenium A powerful tool for automating web browsers and conducting web tests
tenacity Retrying library
visual-regression-tracker Performs visual regression testing
xlrd Library for reading data and formatting information from Excel files

โš™๏ธ Setup Instructions

Step 1: Clone the project

git clone https://github.com/nirtal85/Selenium-Python-Example.git
cd selenium-python-example

Step 2: Create and activate a virtual environment

For Windows:

py -m pip install --user virtualenv
py -m venv env
.\env\Scripts\activate

For Mac:

python3 -m pip install --user virtualenv
python3 -m venv venv
source venv/bin/activate

Step 3: Install Poetry

pip install poetry

Step 4: Install Project Dependencies

poetry install --no-root

Step 5: Create .env File

Create a .env file in the project root directory to securely store project secrets and configuration variables. This file will be used to define key-value pairs for various parameters required by the project. Add the following properties to the .env file:

Parameter Description Example Value
EMAIL Your email address for authentication "your@email.com"
PASSWORD Your secret password for authentication "your_secret_password"
VRT_APIURL Visual Regression Tracker API URL "https://vrt.example.com/api"
VRT_PROJECT Visual Regression Tracker Project ID "project_id"
VRT_CIBUILDID Visual Regression Tracker Build Number "build_number"
VRT_BRANCHNAME Visual Regression Tracker Branch Name "main"
VRT_APIKEY Visual Regression Tracker API Key "your_api_key"
VRT_ENABLESOFTASSERT Enable Soft Assertions True (or False)
MAILINATOR_API_KEY API Key for Mailinator service "your_mailinator_api_key"
MAILINATOR_DOMAIN_NAME Domain name for Mailinator "your_mailinator_domain"

๐Ÿƒโ€โ™‚๏ธ Running Tests

pytest --driver <firefox/chrome_headless>

When no browser was selected then chrome will be used.

  • Run according to tags:
pytest -m <tag_name> --browser <firefox/chrome_headless>

๐Ÿ“Š Viewing Test Results

Install Allure Commandline To View Test results

For Windows:

Follow the instructions here to install Scoop.
Run the following command to install Allure using Scoop:

scoop install allure

For Mac:

brew install allure

View Results Locally:

allure serve allure-results

View Results Online:

View allure results via Github pages

โ„น๏ธ View Help And Other CLI Options

pytest --help

Pre Commit

Run Pre Commit Checks Automatically

pre-commit install

Bump Pre Commit Hooks Version

pre-commit autoupdate

Run Pre Commit Checks Manually On The Entire Project

pre-commit run --all-files

About

Selenium Python example project with pytest and Allure report

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages