Backend Development 7 min read

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 benefits, implementation steps, and how it enhances maintainability, scalability, and CI integration.

360 Quality & Efficiency
360 Quality & Efficiency
360 Quality & Efficiency
A Selenium‑Based UI Automation Framework Using POM, Pytest, and YML Data‑Driven Design

The framework is built on Selenium and follows the Page Object Model (POM) with a four‑layer design: element‑locating layer, page‑object layer, test‑data layer, and test‑case layer, each encapsulating specific responsibilities such as element actions, page logic, data handling, and test execution.

Core modules include Configs for environment‑specific settings and global variables, and Utils that provide common helpers like configuration reading, API requests, YML parsing, file uploads, and logging.

Configuration files are modularized to improve code reuse; a global switch in global.cfg can control the execution environment, allowing different test accounts or database connections without changing source code.

Test data is stored in YML files, offering key‑value readability and easy maintenance. Each business scenario (e.g., login, registration) has separate YML files for normal and abnormal cases.

The Page Object design encapsulates UI elements and actions, reducing redundancy; changes to element locators only require updates in the corresponding page class, improving maintainability.

Pytest is used as the test runner. The project contains pytest.ini for global configuration (test collection rules, tags, command‑line options) and conftest.py for fixtures that set up and tear down test preconditions.

Test execution can be filtered by tags, rerun failed cases, run in parallel, and generate Allure reports with logs and screenshots.

Practical usage steps include locating elements in the pages layer, creating page‑object classes that inherit from BasePage , writing test cases in the testcases layer that operate on page objects, organizing YML test data in the data layer, and running tests via a run.py script that supports tag‑based selection.

The framework’s modularity makes it easy to adapt to new projects by updating only the POM layer, while its Pytest‑based execution integrates smoothly with CI pipelines and Selenium‑Grid for distributed test runs, significantly improving efficiency for UI automation.

PythonUI AutomationTest FrameworkSeleniumpytestPOMYML
360 Quality & Efficiency
Written by

360 Quality & Efficiency

360 Quality & Efficiency focuses on seamlessly integrating quality and efficiency in R&D, sharing 360’s internal best practices with industry peers to foster collaboration among Chinese enterprises and drive greater efficiency value.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.