Skip to content

Commit b99b52b

Browse files
author
dmy.berezovskyi
committed
added example of failed screenshot updated README.md
1 parent d55bae0 commit b99b52b

2 files changed

Lines changed: 79 additions & 75 deletions

File tree

README.md

Lines changed: 75 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,101 @@
1+
12
# Simple Python Selenium UI Automation Framework
23

3-
This is a simple UI automation framework built with:
4-
- Python: 3.9-3.12, pytest 7.2.0, Selenium: 4.24.0 and GitHub Actions CI
5-
<br>
4+
A simple UI automation framework built with:
5+
- **Python**: 3.9 - 3.12
6+
- **pytest**: 7.2.0
7+
- **Selenium**: 4.24.0
8+
- **CI**: GitHub Actions
69

710
[![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue)](https://www.linkedin.com/in/dmytro-berezovskyi/)
811

9-
10-
1112
## Features
1213

13-
- Easy-to-use UI automation framework.
14-
- Based on popular Python libraries: pytest and Selenium.
15-
- Supports Chrome,Firefox and Remote browsers for UI testing.
16-
- Provides utilities for setting up and managing WebDriver instances.
17-
- Supports GitHub Actions CI workflow for Darwin(Mac) and Linux
18-
- Supports different environments: dev, stage
19-
- Supports pytest reports and custom logs
14+
- User-friendly UI automation framework.
15+
- Built on popular Python libraries: pytest and Selenium.
16+
- Supports **Chrome**, **Firefox**, and **Remote** browsers for UI testing.
17+
- Utilities for setting up and managing WebDriver instances.
18+
- Integrated with **GitHub Actions** CI workflow for Darwin (Mac) and Linux.
19+
- Supports multiple environments: **dev**, **stage**.
20+
- Generates **pytest reports** and **custom logs**.
2021

2122
## Getting Started
2223

2324
### Prerequisites
2425

25-
- Python 3.8-3.12
26-
- Note, if you are not using MacOS with arm64 architecture or Selenium version below 4.24.0,
27-
*upload the appropriate driver corresponding to your OS to the resources directory*
26+
- Python 3.8 - 3.12
27+
- 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 the `resources` directory.
2828

29-
### Usage locally
29+
### Local Usage
3030

31-
1. Clone this repository
32-
2. Install required dependencies with
33-
```shell
31+
1. Clone this repository:
32+
```bash
33+
git clone <repository-url>
34+
```
35+
2. Install required dependencies:
36+
```bash
3437
pip install poetry
3538
poetry shell
3639
poetry install
37-
pip install -r requirements.txt
3840
```
39-
3. Create .env file and add
40-
4. Download driver to resources directory:
41-
- rename chromedriver to local if you want to run tests locally
42-
```
43-
DEV_URL = "your-dev-project-url"
44-
STAG_URL = "your-staging-project-url"
45-
```
46-
4. If you don't want to use environment variables, add your references to the properties file
47-
```
48-
class Properties:
49-
_ENV_VARIABLES = {
50-
"dev": ("DEV_URL", ""),
51-
"stag": ("STAG_URL", ""),
52-
# Add more environments and their default URLs as needed
53-
}
54-
```
55-
56-
### Latest drivers
41+
3. Create a `.env` file and add:
42+
```plaintext
43+
DEV_URL = "your-dev-project-url"
44+
STAG_URL = "your-staging-project-url"
45+
```
46+
- Rename the `chromedriver` to `local` if you want to run tests locally.
47+
48+
4. If you prefer not to use environment variables, add your references to the properties file:
49+
```python
50+
class Properties:
51+
_ENV_VARIABLES = {
52+
"dev": ("DEV_URL", ""),
53+
"stag": ("STAG_URL", ""),
54+
# Add more environments and their default URLs as needed
55+
}
56+
```
57+
58+
### Latest Drivers
59+
5760
- #### [Chrome Drivers](https://googlechromelabs.github.io/chrome-for-testing/#stable)
5861
- #### [Firefox Drivers](https://github.com/mozilla/geckodriver)
59-
- It is possible to download the latest version of the driver for MacOS arch64 using chromedriver.sh located in the resources folder
60-
62+
- You can download the latest version of the driver for macOS ARM64 using the `chromedriver.sh` script located in the `resources` folder.
6163

6264
### TODO
6365

64-
| Item | Status |
65-
|------------------------------------------------------|----------------------------------------------------------|
66-
| 1. drivers factory: local, remote, [chrome, firefox] | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
67-
| 2. pytest.ini config: addopts, errors, markers | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
68-
| 3. environments: dev, stag, prod | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
69-
| 4. secrets | ![Status](https://img.shields.io/badge/TODO-yellow) |
70-
| 5. utilities: yaml_reader, logger | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
71-
| 6. BasePage: wait strategy, base actions | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
72-
| 7. Properties: make properties helper | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
73-
| 8. CI: GitHub Actions: runs tests, publish reports | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
66+
| Item | Status |
67+
|-------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
68+
| 1. Drivers factory: local, remote, [Chrome, Firefox] | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
69+
| 2. `pytest.ini` config: addopts, errors, markers | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
70+
| 3. Environments: dev, stag, prod | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
71+
| 4. Secrets | ![Status](https://img.shields.io/badge/TODO-yellow) |
72+
| 5. Utilities: YAML reader, logger | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
73+
| 6. BasePage: wait strategy, base actions | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
74+
| 7. Properties: make properties helper | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
75+
| 8. CI: GitHub Actions: run tests, publish reports, take screenshots on failure (check test summary artifacts) | ![Status](https://img.shields.io/badge/DONE-brightgreen) |
7476

7577
### CI: GitHub Actions
76-
#### *Pay attention*
77-
- While running CI on your local, git resources must contain proper chrome driver with x86_64 architecture
78-
- (unless you are using selenium version 4.11.0 and higher)
79-
- Go to repository settings -> secrets and variables -> actions -> variables and add DEV_URL, STAG_URL
80-
- Added CI configuration to run tests for ubuntu *run_test_ubuntu.yaml*
81-
82-
### Local: Ruff lint configuration
83-
Linting Rules: The configuration defines a set of rules that dictate which linting checks are performed.
84-
You can customize these rules to suit the project's coding style and requirements.
85-
- Create External tools to run linting
86-
- Working directory
87-
```
88-
$ProjectFileDir$
89-
```
90-
- Program
91-
```
92-
path to your ruff installed /bin/ruff
93-
```
94-
- Arguments
95-
```
96-
$FilePathRelativeToProjectRoot$ --config .ruff.toml
97-
```
9878

79+
#### *Important Notes*
80+
81+
- When running CI locally, ensure your Git resources contain the correct Chrome driver with x86_64 architecture (unless using Selenium version 4.11.0 or higher).
82+
- Go to **Repository Settings** -> **Secrets and Variables** -> **Actions** -> **Variables**, and add `DEV_URL`, `STAG_URL`.
83+
- CI configuration is available for running tests on Ubuntu in `run_test_ubuntu.yaml`.
84+
85+
### Local: Ruff Lint Configuration
86+
87+
The linting configuration defines rules that dictate the checks performed. Customize these rules to suit your project's coding style and requirements.
88+
89+
1. Create external tools to run linting.
90+
2. Set the working directory to:
91+
```plaintext
92+
$ProjectFileDir$
93+
```
94+
3. Specify the program:
95+
```plaintext
96+
path to your ruff installed /bin/ruff
97+
```
98+
4. Provide the arguments:
99+
```plaintext
100+
$FilePathRelativeToProjectRoot$ --config .ruff.toml
101+
```

tests/test_main_page.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def test_main5(self, make_driver):
1414
def test_main6(self, make_driver):
1515
make_driver
1616

17-
def test_example(self, make_driver):
18-
driver = make_driver
19-
assert driver.title == "Example sad as Domain" # This will fail to demonstrate screenshot capture
17+
# def test_fail_example(self, make_driver):
18+
# """stores screenshot to job summary artifacts"""
19+
# driver = make_driver
20+
# assert driver.title == "Example sad as Domain"

0 commit comments

Comments
 (0)