Skip to content

Add tox for Python testing #2285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 36 additions & 13 deletions examples/python/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,61 @@
# Running all tests from Selenium python example
# Running tests from Selenium Python examples

Follow these steps to run all test example from selenium python

1. Clone this repository
#### 1. Clone this repository

```
git clone https://github.com/SeleniumHQ/seleniumhq.github.io.git
```

2. Navigate to `python` directory
#### 2. Navigate to `python` directory

```
cd seleniumhq.github.io/examples/python
```

3. Install dependencies using pip
#### 3. Create a virtual environment

- On Windows:

```
py -m venv venv
venv\Scripts\activate
```

- On Linux/Mac:

```
python3 -m venv venv
source venv/bin/activate
```

#### 4. Install dependencies:

```
pip install -r requirements.txt
```
> if you are on a different python version, for example python3.x you may have to replace `pip` with `pip3`

4. Run all tests
> for help, see: https://packaging.python.org/en/latest/tutorials/installing-packages

#### 5. Run tests

- Run all tests with the default Python interpreter:

```
pytest
```

> Please keep some patience - If you are doing it for the first time, it will take a little while to verify and download the browser drivers
- Run all tests with every installed/supported Python interpreter:

## Execute a specific example
To run a specific Selenium Python example, use the following command:
```bash
```
tox
```

> Please have some patience - If you are doing it for the first time, it will take a little while to download the browser drivers

- Run a specific example:

```
pytest path/to/test_script.py
```

Make sure to replace `path/to/test_script.py` with the path and name of the example you want to run.
> Make sure to replace `path/to/test_script.py` with the path and name of the example you want to run
1 change: 1 addition & 0 deletions examples/python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pytest-trio==0.8.0
pytest-rerunfailures==15.0
flake8==7.2.0
requests==2.32.3
tox==4.25.0
30 changes: 30 additions & 0 deletions examples/python/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Tox (https://tox.wiki/) is a tool for running tests in multiple
# virtualenvs. This configuration file will run the test suite on all
# supported python versions. To use it, run "tox" from this directory.
#
# For a specific environment, run: "tox -e <env>" (i.e.: "tox -e py313")
#
# This tox configuration will skip any Python interpreters that can't be found.
# To manage multiple Python interpreters for covering all versions, you can use
# pyenv: https://github.com/pyenv/pyenv


[tox]
env_list =
py39
py310
py311
py312
py313
skip_missing_interpreters = True

[testenv]
description = run tests
passenv = *
deps =
-r requirements.txt
commands =
# "-vv" means extra verbose
# "-r fEsxXp" means show extra test summary info as specified by:
# (f)ailed, (E)rror, (s)kipped, (x)failed, (X)passed, (p)assed
pytest -vv -r fEsxXp {posargs:.}
Loading