|
| 1 | + |
1 | 2 | # Simple Python Selenium UI Automation Framework |
2 | 3 |
|
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 |
6 | 9 |
|
7 | 10 | [](https://www.linkedin.com/in/dmytro-berezovskyi/) |
8 | 11 |
|
9 | | - |
10 | | - |
11 | 12 | ## Features |
12 | 13 |
|
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**. |
20 | 21 |
|
21 | 22 | ## Getting Started |
22 | 23 |
|
23 | 24 | ### Prerequisites |
24 | 25 |
|
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. |
28 | 28 |
|
29 | | -### Usage locally |
| 29 | +### Local Usage |
30 | 30 |
|
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 |
34 | 37 | pip install poetry |
35 | 38 | poetry shell |
36 | 39 | poetry install |
37 | | - pip install -r requirements.txt |
38 | 40 | ``` |
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 | + |
57 | 60 | - #### [Chrome Drivers](https://googlechromelabs.github.io/chrome-for-testing/#stable) |
58 | 61 | - #### [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. |
61 | 63 |
|
62 | 64 | ### TODO |
63 | 65 |
|
64 | | -| Item | Status | |
65 | | -|------------------------------------------------------|----------------------------------------------------------| |
66 | | -| 1. drivers factory: local, remote, [chrome, firefox] |  | |
67 | | -| 2. pytest.ini config: addopts, errors, markers |  | |
68 | | -| 3. environments: dev, stag, prod |  | |
69 | | -| 4. secrets |  | |
70 | | -| 5. utilities: yaml_reader, logger |  | |
71 | | -| 6. BasePage: wait strategy, base actions |  | |
72 | | -| 7. Properties: make properties helper |  | |
73 | | -| 8. CI: GitHub Actions: runs tests, publish reports |  | |
| 66 | +| Item | Status | |
| 67 | +|-------------------------------------------------------------------------------------------------------------|----------------------------------------------------------| |
| 68 | +| 1. Drivers factory: local, remote, [Chrome, Firefox] |  | |
| 69 | +| 2. `pytest.ini` config: addopts, errors, markers |  | |
| 70 | +| 3. Environments: dev, stag, prod |  | |
| 71 | +| 4. Secrets |  | |
| 72 | +| 5. Utilities: YAML reader, logger |  | |
| 73 | +| 6. BasePage: wait strategy, base actions |  | |
| 74 | +| 7. Properties: make properties helper |  | |
| 75 | +| 8. CI: GitHub Actions: run tests, publish reports, take screenshots on failure (check test summary artifacts) |  | |
74 | 76 |
|
75 | 77 | ### 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 | | -``` |
98 | 78 |
|
| 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 | + ``` |
0 commit comments