Selenium Python E2E

Structure Selenium pytest E2E tests with Page Object Models and centralized webdriver fixtures.

1|Updated May 2, 2026
One-click install
npx skills add https://github.com/Levironexe/architect --skill selenium-python-e2e
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Selenium Python E2E
Source: https://github.com/Levironexe/architect/tree/main/skills/patterns/selenium-python
Command: npx skills add https://github.com/Levironexe/architect --skill selenium-python-e2e

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires selenium, webdriver-manager, pytest.

What problem does it solve?

E2E testing in a growing Python web project becomes slow and flaky when tests duplicate browser setup, sprinkle raw locators everywhere, and rely on fixed sleeps instead of reliable synchronization. This Skill standardizes Selenium + pytest structure so your coding agent can refactor tests safely while keeping interactions deterministic.

Core Features & Use Cases

  • Page Object Model with explicit waits: Consolidates locators and user flows into tests/pages/ using a shared BasePage with WebDriverWait and expected conditions, avoiding time.sleep().
  • Centralized driver lifecycle: Ensures webdriver.Chrome() (or Remote) is created only in conftest.py via a single pytest fixture, enabling consistent local/CI behavior.
  • Failure diagnostics and maintainability: Captures screenshots on test failure using a pytest hook/fixture finalizer, and enforces conventions that keep tests free of raw find_element() and By usage.
  • Auth and integration coverage: Encourages dedicated authentication test modules for redirects, login/logout/session handling, and protected-page access control.

Quick Start

Ask your agent to generate a Selenium + pytest E2E test suite skeleton that follows the required tests/pages/, conftest.py, and explicit-waits structure for your application.

Frequently Asked Questions about Selenium Python E2E

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure Selenium pytest tests to avoid flaky execution and fixed sleeps?

Structure Selenium pytest tests using the Page Object Model with a shared BasePage that enforces WebDriverWait and expected_conditions, eliminating time.sleep() calls. This standardizes browser interactions and keeps regression suites deterministic across local and CI environments.

What is the best way to manage webdriver lifecycle in a pytest E2E suite?

The best way to manage webdriver lifecycle in pytest is creating the browser instance exclusively within conftest.py via a single pytest fixture. This centralizes driver creation, ensuring consistent behavior and teardown for both local and Remote WebDriver executions.

Can I use explicit waits and Page Objects for Selenium Python authentication flows?

Yes, you can implement explicit waits and Page Objects for Selenium Python authentication flows by consolidating locators and user journeys into dedicated test modules. This reliably handles login, logout, redirects, and protected-page access control.

How do I capture screenshots automatically when a pytest Selenium test fails?

You capture screenshots automatically on pytest Selenium test failures by implementing a pytest hook or fixture finalizer. This triggers image capture during the teardown phase, providing reliable failure diagnostics for your E2E regression suite.

Why should I avoid raw find_element and By locators in my Selenium E2E tests?

You should avoid raw find_element and By locators in Selenium E2E tests because sprinkling them throughout scripts reduces maintainability. Centralizing locators inside Page Objects keeps tests clean, allows safe refactoring, and prevents flaky synchronization.