A simple CLI to create a Selenium POM project structure.
Project description
Python Selenium Automation Framework
Overview
This is a professional and robust base for a Python Selenium automation framework, built using the Page Object Model (POM) design pattern. It provides a solid foundation for creating scalable and maintainable web automation scripts.
The framework is designed to be easily extensible. You can add new page objects, tests, and utility functions to suit your specific needs.
Features
- Page Object Model (POM): A design pattern that creates a clear separation between test code and page-specific code.
- Cross-Browser Support: Easily run tests on Chrome, Firefox, and Edge.
- Explicit Waits: Uses
WebDriverWaitto handle dynamic elements, avoiding unreliabletime.sleep()calls. - Centralized Driver Management: A
DriverFactoryto manage WebDriver instances. - Dependency Management: All required packages are listed in
requirements.txt. - Professional Structure: A clean and organized project structure that is easy to understand and maintain.
Project Structure
.
├── config/
│ └── config.py
├── pages/
│ ├── __init__.py
│ └── base_page.py
├── utils/
│ ├── __init__.py
│ └── driver_factory.py
├── .gitignore
├── main.py
└── requirements.txt
config/: Contains configuration files, such as URLs, credentials, and other settings.pages/: Contains page object classes. Each class represents a page in the web application and contains the locators and methods for interacting with that page.utils/: Contains utility classes and functions, such as theDriverFactoryfor creating WebDriver instances.main.py: The entry point of the application.requirements.txt: A file listing the Python packages required for the project..gitignore: Specifies which files and directories to ignore in a Git repository.
Getting Started
Prerequisites
- Python 3.6+
pip(Python package installer)
Installation
-
Clone the repository:
git clone <your-repo-url> cd <your-repo-directory>
-
Create a virtual environment (recommended):
# Create a virtual environment python -m venv .venv # Activate the virtual environment: # On Mac/Linux: source .venv/bin/activate # On Windows: # Git Bash: source .venv/Scripts/activate # CMD: .venv\Scripts\activate.bat # PowerShell: .venv\Scripts\Activate.ps1
-
Install the dependencies:
pip install -r requirements.txt
Running the Automation
To run the automation script, execute the main.py file from the root directory:
python main.py
The script will prompt you to enter a URL and choose a browser (chrome, firefox, or edge).
Page Object Model (POM)
This framework uses the Page Object Model (POM), which is a design pattern that enhances test maintenance and reduces code duplication. In POM, each web page in the application is represented as a class. This class contains the locators for the elements on the page and the methods to interact with those elements.
The pages/base_page.py file contains a BasePage class from which all other page object classes should inherit. This base class includes common methods like finding elements, clicking, sending keys, etc., using explicit waits for robustness.
Dependencies
selenium: The main library for browser automation.webdriver-manager: A library that automatically manages the binaries for web drivers (e.g., chromedriver, geckodriver).
sel-pom: Selenium POM Project Creator
sel-pom is a command-line tool to quickly set up a new Python Selenium automation project using the Page Object Model (POM) architecture.
Features
- Generate Projects Instantly: Create a new, professionally structured Selenium project with a single command.
- Page Object Model (POM): The generated project follows the POM design pattern for maintainable and scalable automation.
- Best Practices: Includes built-in support for explicit waits, cross-browser testing, and dependency management.
Installation
You can install sel-pom directly from this repository for local use.
-
Clone the repository:
git clone <your-repo-url> cd sel-pom-creator # Or your project's root folder
-
Install in editable mode: This command installs the package on your system, and any changes you make to the source code will be immediately available.
pip install -e .
Usage
Once installed, you can create a new project by running:
sel-pom new <your-project-name>
Replace <your-project-name> with the desired name for your new project. This will create a new directory with the following structure:
<your-project-name>/
├── config/
│ └── config.py
├── pages/
│ ├── __init__.py
│ └── base_page.py
├── utils/
│ ├── __init__.py
│ └── driver_factory.py
├── .gitignore
├── main.py
└── requirements.txt
Running Your New Project
To run the automation script in your newly created project:
-
Navigate to the project directory:
cd <your-project-name>
-
Install dependencies:
pip install -r requirements.txt
-
Run the main script:
python main.py
The script will prompt you to enter a URL and choose a browser.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sel_pom-0.0.1.tar.gz.
File metadata
- Download URL: sel_pom-0.0.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84557244d1d8b6c9a7ef4013af6066ef5be7cf35644ee7ecacbabe75c09b4c2b
|
|
| MD5 |
66fa55f1985ec2e528ede059e5e4d521
|
|
| BLAKE2b-256 |
5ceffcb408b916c00e7475fd78702493b855ba3b7f5f1c4f798ad5010faec698
|
File details
Details for the file sel_pom-0.0.1-py3-none-any.whl.
File metadata
- Download URL: sel_pom-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f78f0e76c92aefb0cd51f4cc758daa43af033cf5157c50f84b73b3831f460625
|
|
| MD5 |
8c18cff4509b20e3807fcdb611d14f79
|
|
| BLAKE2b-256 |
5119dbd4dba92b29bfdd640011305fd2e64bfd584923663c17a51153e5bdd461
|