home / skills / partme-ai / full-stack-skills / selenium

selenium skill

/skills/selenium

This skill provides comprehensive guidance for Selenium WebDriver, helping you automate browsers, write reliable tests, and master locators and waits.

npx playbooks add skill partme-ai/full-stack-skills --skill selenium

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
667 B
---
name: selenium
description: Provides comprehensive guidance for Selenium WebDriver including browser automation, element location, waits, and test frameworks. Use when the user asks about Selenium, needs to automate web browsers, write Selenium tests, or work with Selenium WebDriver.
license: Complete terms in LICENSE.txt
---

## When to use this skill

Use this skill whenever the user wants to:
- [待完善:根据具体工具添加使用场景]

## How to use this skill

[待完善:根据具体工具添加使用指南]

## Best Practices

[待完善:根据具体工具添加最佳实践]

## Keywords

[待完善:根据具体工具添加关键词]

Overview

This skill provides practical, hands-on guidance for using Selenium WebDriver to automate web browsers, locate elements, manage waits, and integrate with test frameworks. It focuses on Python examples, common patterns, and troubleshooting tips to help you build reliable browser automation and end-to-end tests. The content is aimed at developers and QA engineers who need actionable steps and clear examples.

How this skill works

The skill inspects typical Selenium workflows and explains how to start a WebDriver session, find elements with robust selectors, use explicit and implicit waits, and handle common browser interactions (clicks, inputs, navigation). It demonstrates how to structure tests using pytest or unittest, manage browser drivers, and capture logs or screenshots for debugging. The guidance highlights anti-flakiness patterns and cross-browser considerations.

When to use it

  • Automating repetitive web UI tasks like form submission or data extraction
  • Writing end-to-end tests for web applications using Python and Selenium
  • Creating cross-browser compatibility checks and smoke tests
  • Debugging flaky UI tests and improving test stability
  • Integrating browser automation into CI pipelines

Best practices

  • Prefer explicit waits (WebDriverWait) over implicit waits to avoid timing issues
  • Use stable selectors: IDs, data-* attributes, or robust CSS/XPath rather than brittle text-based locators
  • Keep tests independent and idempotent; reset state between tests
  • Run headless only in CI; debug locally with headed browser sessions and screenshots
  • Parameterize browser and environment settings to test multiple configurations easily
  • Use page object pattern to encapsulate page behaviors and improve maintainability

Example use cases

  • Automate login, fill forms, and verify resulting UI changes in a web app
  • Scrape dynamic content that loads via JavaScript by waiting for elements to appear
  • Write pytest-based UI tests that run in CI across Chrome and Firefox
  • Capture screenshots on test failure and save browser console logs for investigations
  • Implement a page object for a checkout flow to reduce duplicate selectors and actions

FAQ

Do I need a separate browser driver binary?

Yes. For most browsers you need the matching driver binary (chromedriver, geckodriver). Use tools like webdriver-manager or webdriver-manager-python to download and manage drivers automatically.

Should I use implicit or explicit waits?

Prefer explicit waits (WebDriverWait with expected_conditions) for specific element states. Implicit waits can cause unpredictable interactions when combined with explicit waits.

How do I reduce flaky tests?

Stabilize selectors, use explicit waits for asynchronous content, avoid hard sleeps, isolate test data, and run tests against reproducible environments (containers or dedicated test accounts).