playwright-patterns

Guide Playwright automation scripts with best practices and patterns.

8|1|Updated Feb 25, 2022
One-click install
npx skills add https://github.com/ayubun/dotfiles --skill playwright-patterns-ayubun
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: playwright-patterns
Source: https://github.com/ayubun/dotfiles/tree/main/configs/opencode/skills/ed3d-playwright/playwright-patterns
Command: npx skills add https://github.com/ayubun/dotfiles --skill playwright-patterns-ayubun

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to best practices and patterns for writing robust Playwright automation scripts, enhancing maintainability and reducing test flakiness.

Core Features & Use Cases

  • Selector Strategy: Offers guidelines for choosing the right selectors and prioritizing user-facing locators.
  • Waiting Patterns: Teaches how to effectively handle waiting for elements and network conditions.
  • Data Extraction: Demonstrates methods for extracting text and structured data from web pages.
  • Error Handling: Provides strategies for graceful error handling and fallbacks.
  • Navigation: Shows how to navigate through multi-page workflows and handle new tabs.
  • Form Interaction: Offers patterns for filling out forms and handling file uploads.
  • Screenshot and Debugging: Provides tips for taking strategic screenshots and using debug mode.
  • Common Patterns Reference: Summarizes common automation patterns with examples.
  • Anti-Pattern Checklist: Warns against common mistakes to avoid in automation scripts.

Quick Start

Run the skill to review the best practices for Playwright automation.

Frequently Asked Questions about playwright-patterns

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

FAQPage Schema
What's the best way to write robust Playwright automation scripts?

Robust Playwright automation scripts follow established patterns for selector strategies, waiting, and error handling. Using user-facing locators and avoiding anti-patterns reduces test flakiness and enhances maintainability.

How do I handle waiting for elements and network conditions in Playwright?

Handling waiting in Playwright requires specific patterns to effectively wait for elements and network conditions. Proper waiting patterns prevent premature execution errors and ensure automation scripts interact with fully loaded pages.

How do I extract structured data from web pages using Playwright?

Extracting structured data using Playwright involves targeted methods for pulling text and structured information from web pages. These data extraction patterns streamline web scraping tasks and ensure accurate data capture.

Why are my Playwright e2e testing scripts flaky and how can I fix them?

Flaky Playwright e2e testing scripts usually stem from poor selector choices and inadequate waiting patterns. Fixing them involves applying best practices for navigation, form interaction, and avoiding common automation anti-patterns.

How do I handle multi-page navigation and new tabs in Playwright?

Handling multi-page navigation and new tabs in Playwright requires specific patterns for moving through workflows. These navigation patterns ensure scripts maintain context and manage page transitions correctly.

What are common anti-patterns to avoid in Playwright web scraping?

Common anti-patterns in Playwright web scraping include brittle selectors and improper waiting conditions. Reviewing an anti-pattern checklist helps identify and avoid these mistakes, leading to more reliable and maintainable automation scripts.