|  | 
| 1 |  | -# self-python | 
| 2 |  | -python/self testing framework | 
|  | 1 | +# Playwright Python Example | 
| 3 | 2 | 
 | 
| 4 |  | -## setup | 
| 5 |  | -- clone repo | 
| 6 |  | -- create python virtual environment: `python -m venv venv` | 
| 7 |  | -- activate environment: `source venv/bin/activate` | 
|  | 3 | +This project contains UI and API tests for the [DemoQA](https://demoqa.com) QA training platform. Tests are written with [Pytest](https://docs.pytest.org/) and use [Playwright](https://playwright.dev/python/) for browser automation and API requests. | 
| 8 | 4 | 
 | 
| 9 |  | -## run tests | 
| 10 |  | -- install requirements: `pip install -r requierements.txt` | 
| 11 |  | -- run tests: `pytest` | 
|  | 5 | +## Setup | 
| 12 | 6 | 
 | 
| 13 |  | -## Alternative way of running tests | 
| 14 |  | -- `make install` | 
| 15 |  | -- `make test`,  `make-test-ui` etc. (see [Makefile](./Makefile)) | 
|  | 7 | +1. Clone this repository. | 
|  | 8 | +2. Create and activate a virtual environment: | 
|  | 9 | +   ```bash | 
|  | 10 | +   python -m venv venv | 
|  | 11 | +   source venv/bin/activate | 
|  | 12 | +   ``` | 
|  | 13 | +3. Install dependencies and Playwright browsers: | 
|  | 14 | +   ```bash | 
|  | 15 | +   pip install -r requirements.txt | 
|  | 16 | +   playwright install --with-deps | 
|  | 17 | +   ``` | 
|  | 18 | +4. Copy `.env.example` to `.env` and adjust the `DOMAIN` variable if needed. | 
| 16 | 19 | 
 | 
| 17 |  | -## misc | 
| 18 |  | -- after running `make test` reports will be generated under [reports](./reports) folder | 
|  | 20 | +## Running tests | 
|  | 21 | + | 
|  | 22 | +To run all tests use `pytest`: | 
|  | 23 | + | 
|  | 24 | +```bash | 
|  | 25 | +pytest | 
|  | 26 | +``` | 
|  | 27 | + | 
|  | 28 | +You can run specific test types using markers: | 
|  | 29 | + | 
|  | 30 | +```bash | 
|  | 31 | +pytest -m ui    # run UI tests only | 
|  | 32 | +pytest -m api   # run API tests only | 
|  | 33 | +``` | 
|  | 34 | + | 
|  | 35 | +The provided `Makefile` offers shortcuts: | 
|  | 36 | + | 
|  | 37 | +```bash | 
|  | 38 | +make install   # install dependencies | 
|  | 39 | +make test      # run tests and generate reports | 
|  | 40 | +``` | 
|  | 41 | + | 
|  | 42 | +### Reports | 
|  | 43 | + | 
|  | 44 | +After running `make test` reports are stored in the `reports` directory (HTML under `reports/html` and JUnit XML under `reports/xml`). | 
|  | 45 | + | 
|  | 46 | +## Docker | 
|  | 47 | + | 
|  | 48 | +A `Dockerfile` is available to execute the tests inside a container: | 
|  | 49 | + | 
|  | 50 | +```bash | 
|  | 51 | +docker build -t playwright-tests . | 
|  | 52 | +docker run --rm playwright-tests | 
|  | 53 | +``` | 
0 commit comments