selenium-automation

Automates browser testing with Selenium WebDriver using Page Object Model and explicit waits.

Updated Jan 31, 2023
One-click install
npx skills add https://github.com/Briian3306/Transporte --skill selenium-automation-briian3306
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: selenium-automation
Source: https://github.com/Briian3306/Transporte/tree/main/.agents/skills/selenium-automation
Command: npx skills add https://github.com/Briian3306/Transporte --skill selenium-automation-briian3306

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires selenium, webdriver-manager, pytest, pytest-xdist, pytest-html, allure-pytest.

What problem does it solve? Writing reliable browser automation tests is hard: flaky selectors, timing issues with dynamic content, and unmaintainable test code cause constant failures. This Skill provides expert guidance for building stable Selenium WebDriver test suites with proven patterns. ## Core Features & Use Cases - Page Object Model Implementation: Structure tests with reusable page classes, base pages, and driver factories for maintainable code. - Wait and Synchronization Strategies: Apply explicit waits with expected conditions instead of fragile sleeps to handle dynamic content. - Element Location Best Practices: Choose reliable locators (ID, CSS, XPath) and handle dropdowns, alerts, frames, and multiple windows. - Use Case: You need to automate login and dashboard testing for a web app across Chrome and Firefox. Use this Skill to generate a pytest-based test suite with fixtures, page objects, and headless execution. ## Quick Start Write a Selenium test suite using the Page Object Model to test the login flow of my web application with pytest fixtures and explicit waits.

Frequently Asked Questions about selenium-automation

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

FAQPage Schema
How do I write Selenium tests with the Page Object Model?▼

Create a BasePage class wrapping WebDriverWait and common actions like click and text entry, then subclass it per page with locators as class attributes. Tests instantiate page objects and call high-level methods like login(), keeping test code separate from locator logic.

What is the best way to wait for elements in Selenium?▼

Use explicit waits via WebDriverWait with expected conditions such as element_to_be_clickable or visibility_of_element_located. Avoid time.sleep() and prefer explicit waits over implicit waits for handling dynamic content reliably.

Which element locator strategy is most reliable in Selenium?▼

ID is the most reliable locator, followed by name and CSS selectors. Use XPath for complex relationships like sibling traversal, and avoid fragile selectors based on deep structural paths or classes that change frequently.

Can Selenium run tests in headless mode and in parallel?▼

Yes, add the --headless argument to Chrome options for headless execution, which speeds up runs. Use pytest-xdist for parallel test execution and Selenium Grid for distributing tests across browsers and machines.

How do I handle dropdowns, alerts, and frames in Selenium?▼

Use the Select class for dropdowns with select_by_visible_text or select_by_value. Switch to alerts via driver.switch_to.alert to accept or dismiss, and use driver.switch_to.frame() for frames, returning with switch_to.default_content().

Why are my Selenium tests flaky and how do I debug them?▼

Flakiness usually comes from hard-coded sleeps, brittle selectors, or race conditions with dynamic content. Replace sleeps with explicit waits, capture screenshots on failure with driver.save_screenshot(), and inspect page source when elements are not found.