diff --git a/examples/python/README.md b/examples/python/README.md index 2db5f25cb9a..9650c07cbb5 100644 --- a/examples/python/README.md +++ b/examples/python/README.md @@ -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. \ No newline at end of file +> Make sure to replace `path/to/test_script.py` with the path and name of the example you want to run diff --git a/examples/python/requirements.txt b/examples/python/requirements.txt index 7c8d8b1d6e0..b8b5db656ee 100644 --- a/examples/python/requirements.txt +++ b/examples/python/requirements.txt @@ -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 diff --git a/examples/python/tox.ini b/examples/python/tox.ini new file mode 100644 index 00000000000..49c6f636bb7 --- /dev/null +++ b/examples/python/tox.ini @@ -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 " (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:.}