|
| 1 | +# Selenium + Python Template Project |
| 2 | + |
| 3 | +Welcome to the Selenium + Python Template Project! This repository provides a well-structured, scalable framework for test automation using Selenium WebDriver and Python. It's designed to help you get started quickly and maintain your test automation efforts efficiently. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 📋 Features |
| 8 | + |
| 9 | +- **Modular Design**: Organized structure with reusable components like PageObjects and Test Data Factories. |
| 10 | +- **Scalability**: Easy to extend for larger projects. |
| 11 | +- **Integration-Ready**: Built-in support for integrating with APIs, CI/CD pipelines, and reporting tools. |
| 12 | +- **Cross-Browser Support**: Pre-configured WebDriver factory for managing multiple browsers. |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## 🏗️ Project Structure |
| 17 | + |
| 18 | +```plaintext |
| 19 | +selenium_python_template/ |
| 20 | +├── .github/workflows/ui-tests.yml # GitHub Workflow |
| 21 | +├── pages/ # PageObject classes |
| 22 | +├── tests/ # Test scripts |
| 23 | +├── utils/ # Utility functions (e.g. text processing) |
| 24 | +├── data/ # Test data files (coming soon) |
| 25 | +├── test-reports/ # Test execution reports |
| 26 | +├── drivers/ # WebDriver binaries (optional) |
| 27 | +├── config/ # Configuration files (coming soon) |
| 28 | +├── requirements.txt # Python dependencies |
| 29 | +├── bitbucket-pipelines.yml # BitBucket Pipelines configuration |
| 30 | +└── conftest.py # Global fixtures |
| 31 | +``` |
| 32 | + |
| 33 | +## 🚀 Getting Started |
| 34 | + |
| 35 | +### Prerequisites |
| 36 | + |
| 37 | +* Python 3.9+ |
| 38 | +* Google Chrome or Firefox or Safari to run & debug tests locally |
| 39 | +* pip (Python package installer) |
| 40 | + |
| 41 | +### Installation |
| 42 | + |
| 43 | +Clone the repository: |
| 44 | + |
| 45 | +```bash |
| 46 | +git clone https://github.com/obrizan/selenium_python_template.git |
| 47 | +cd selenium_python_template |
| 48 | +``` |
| 49 | + |
| 50 | + |
| 51 | +Create and activate virutal environment (optional, but recommended): |
| 52 | + |
| 53 | +```bash |
| 54 | +python -m venv .venv |
| 55 | + |
| 56 | +# On Windows: |
| 57 | +.venv\Scripts\activate |
| 58 | + |
| 59 | +# On macOS/Linux: |
| 60 | +source .venv/bin/activate |
| 61 | +``` |
| 62 | + |
| 63 | +Install dependencies: |
| 64 | + |
| 65 | +```bash |
| 66 | +pip install -r requirements.txt |
| 67 | +``` |
| 68 | + |
| 69 | +Set up WebDriver (optionally): |
| 70 | + |
| 71 | +Download the appropriate WebDriver for your browser (ChromeDriver, GeckoDriver, etc.) |
| 72 | +Place it in the drivers/ directory or update your system PATH. |
| 73 | + |
| 74 | +## ⚙️Configuration |
| 75 | + |
| 76 | +Set environment variables: |
| 77 | + |
| 78 | +| Variable | Description | Default | |
| 79 | +|----------------------|-----------------------------------------------------------------------|--------------------| |
| 80 | +| `SELENIUM_DRIVER_KIND` | Options: `remote`, `chrome`, `safari`, `firefox`. | `chrome` | |
| 81 | +| `REMOTE_DRIVER_URL` | Used when `SELENIUM_DRIVER_KIND=remote`. | `http://localhost:3000` | |
| 82 | +| `WINDOW_RESOLUTION` | Browser window resolution. Values are defined in `webdriver_factory.py` | `DESKTOP_1280X720` | |
| 83 | + |
| 84 | +## 🧪 Running Tests |
| 85 | +Run all tests using pytest: |
| 86 | + |
| 87 | +```bash |
| 88 | +pytest --html=test-reports/report.html --self-contained-html |
| 89 | +``` |
| 90 | + |
| 91 | +Specify a particular test file or function: |
| 92 | + |
| 93 | +```bash |
| 94 | +pytest tests/test_example.py |
| 95 | +``` |
| 96 | + |
| 97 | +## 🛠️ Customization |
| 98 | + |
| 99 | +* **Adding Pages:** Create new classes in pages/ to represent additional pages or components. |
| 100 | +* **Adding Tests:** Write test scripts in tests/ and use the pytest framework for execution. |
| 101 | +* **Configuration:** Update config/ files to customize browser, test data paths, and other settings. |
| 102 | + |
| 103 | +## 📄 License |
| 104 | +This project is licensed under the MIT License. See the LICENSE file for details. |
| 105 | + |
| 106 | +## 🙌 Contributing |
| 107 | +Contributions are welcome! If you'd like to improve this project, feel free to fork the repository and submit a pull request. |
| 108 | + |
| 109 | +## 📞 Contact |
| 110 | +Have questions or suggestions? Reach out: |
| 111 | + |
| 112 | +**Author:** Volodymyr Obrizan |
| 113 | + |
| 114 | +**Email:** volodymyr.obrizan@gmail.com |
| 115 | + |
| 116 | +Happy Testing! 🚀 |
0 commit comments