A Selenium‑Based UI Automation Framework Using POM, Pytest, and YML Data‑Driven Design
This article introduces a modular Selenium UI automation framework built with the Page Object Model, layered architecture, Pytest execution, and YML‑driven test data, explaining its components, configuration files, coding practices, and steps for running tests efficiently in CI environments.
The framework is built on Selenium and follows the Page Object Model (POM) combined with a layered design that separates element locating, page objects, test data, and test cases, while providing common utilities such as logging and configuration handling.
Test cases are written with Pytest and driven by YML files, enabling data‑driven execution and Allure reporting; the Configs folder stores environment‑specific settings and global variables, and the Utils folder offers helper methods for file I/O, API requests, and logging.
Configuration files modularize code and allow global switches to control execution environments, making the framework adaptable to multiple test environments and simplifying maintenance.
The YML approach stores test data in a readable key‑value format, with separate files for normal and abnormal scenarios (e.g., login_success.yml and login_fail.yml ), improving readability and reducing maintenance effort.
Using the POM design, the element‑locating layer encapsulates only the elements needed for each business scenario, while the page‑object layer implements page‑specific actions; this reduces code duplication and eases updates when UI elements change.
Pytest serves as the test runner, with pytest.ini for core configuration and conftest.py for fixtures that handle setup and teardown; command‑line options allow tagging, retrying failed cases, parallel execution, and report generation.
Practical usage steps include locating elements, creating page‑object classes that inherit from a BasePage, organizing test cases in the testcases directory, managing data in YML files, and executing tests via a run.py script that supports tag‑based selection.
The summary emphasizes that the modular POM structure greatly improves usability and maintainability, the Pytest‑based execution integrates smoothly with CI pipelines, and the framework can be scaled to other projects by adjusting only the POM layer, while Selenium‑Grid enables distributed test execution for higher efficiency.
360 Tech Engineering
Official tech channel of 360, building the most professional technology aggregation platform for the brand.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.