npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, πŸ‘‹, I’m Ryan HefnerΒ  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you πŸ™

Β© 2026 – Pkg Stats / Ryan Hefner

playwright-tools

v0.1.6

Published

🎭 A collection of utilities for Playwright TypeScript

Readme

🎭 playwright-tools

A comprehensive collection of utilities for Playwright testing that simplify common testing patterns and enhance your automation workflow.

TypeScript NPM Version License


✨ Features

  • πŸ›‘οΈ Safe Element Interactions - Built-in waits and error handling for reliable interactions
  • πŸ”„ Retry Mechanisms - Exponential backoff retry logic for flaky operations
  • πŸ“Έ Enhanced Screenshots - Timestamped screenshots with debugging annotations
  • πŸ” Element Queries - Existence checks and bulk operations without throwing errors
  • 🌐 Navigation Utilities - Safe navigation with loading state checks
  • ⌨️ Advanced Interactions - File uploads, drag & drop, keyboard shortcuts
  • πŸ“Š Table Utilities - Extract and validate table data efficiently
  • 🎯 Accessibility Helpers - Check ARIA attributes and accessibility properties
  • πŸ’Ύ Storage Management - Handle localStorage and sessionStorage operations
  • 🌍 Network Helpers - Wait for specific requests and monitor network activity
  • πŸ”§ Page Objects - Reusable page object patterns and utilities
  • πŸ“ Test Data Factories - Generate consistent test data across tests
  • πŸ“‹ Assertions - Enhanced assertion helpers for multiple elements
  • ⚑ Test Utilities - Filter and dispatch tests with skip/runOnly flags
  • πŸ§ͺ TypeScript Support - Full type safety with comprehensive TypeScript definitions
  • πŸͺΆ Zero Dependencies - No additional dependencies beyond Playwright

πŸ“¦ Installation

npm install playwright-tools

Peer Dependency: This package requires @playwright/test to be installed in your project.

npm install @playwright/test

πŸš€ Quick Start

Basic Usage

import { safeClick, safeFill, elementExists } from "playwright-tools";

// Safe element interactions
await safeClick(page.locator("#submit-button"));
await safeFill(page.locator("#username"), "[email protected]");

// Check element existence without throwing
const exists = await elementExists(page.locator("#optional-element"));

Modular Imports

Import specific modules for better tree-shaking:

// Import specific modules
import { safeClick, safeFill } from "playwright-tools/interactions";
import { waitForElements, elementExists } from "playwright-tools/element-queries";
import { takeTimestampedScreenshot } from "playwright-tools/screenshots";
import { retryAction } from "playwright-tools/retry";

// Or import everything
import * as pwUtils from "playwright-tools";

πŸ“š Documentation

πŸ“– Complete documentation is available in the docs directory:

Guides & Examples


πŸ’‘ Quick Examples

Form Handling

import { fillForm, safeClick } from "playwright-tools";

await fillForm([
  { locator: page.locator("#username"), value: "john.doe" },
  { locator: page.locator("#password"), value: "secure123" },
  { locator: page.locator("#email"), value: "[email protected]" },
]);

await safeClick(page.locator("#submit"));

Element Queries

import { elementExists, waitForElements } from "playwright-tools";

// Check if element exists without throwing
const exists = await elementExists(page.locator("#optional-element"));

// Wait for multiple elements concurrently
await waitForElements([
  page.locator("#header"),
  page.locator("#navigation"),
  page.locator("#content"),
]);

Network Monitoring

import { waitForNetworkRequest } from "playwright-tools";

// Wait for specific API call
const response = await waitForNetworkRequest(page, "/api/users", {
  method: "GET",
  status: 200,
  timeout: 10000,
});

Retry Logic

import { retryAction } from "playwright-tools";

// Retry flaky operations with exponential backoff
const result = await retryAction(
  async () => {
    await page.click("#sometimes-slow-button");
    return await page.locator("#result").textContent();
  },
  { maxRetries: 3, baseDelay: 1000 }
);

Locator Decorator

The Locator Decorator lets you extend Playwright locators with custom methods, enhanced safe interactions, and even method overrides. This makes your locators more powerful, reusable, and tailored to your app.

Key Features

  • Add your own methods to any locator
  • Use enhanced methods like safeClick, safeFill, extractData, and more
  • Override existing locator methods (e.g., custom click)
  • Factory and page extension patterns for consistent usage

Quick Example

import { createEnhancedLocator, extendPage } from "playwright-tools";

// Enhance a single locator
const enhanced = createEnhancedLocator(page.locator("#my-btn"), {
  customMethods: {
    async highlight() {
      await this.evaluate(el => el.style.border = "2px solid red");
    }
  }
});
await enhanced.safeClick();
await enhanced.highlight();

// Or extend the whole page for consistent usage
const enhancedPage = extendPage(page, {
  customMethods: {
    async waitForAnimation() {
      await this.waitForFunction(() => !document.querySelector('[style*="animation"]'));
    }
  }
});
const btn = enhancedPage.locator("#my-btn");
await btn.safeClick();
await btn.waitForAnimation();

See the full documentation:
πŸ“– Locator Decorator Guide


πŸ”— Quick Links


πŸ“– Resources & Learning Materials

🦎 Practice Application

πŸ‡΅πŸ‡± Polish Resources

πŸ‡¬πŸ‡§ English Resources


πŸ“ž Contact & Support

Feel free to reach out to us:


🌟 Show Your Support

If you found this package helpful:

  • ⭐ Star this repository to show your support
  • πŸ”„ Share with your team to help spread knowledge about advanced Playwright testing patterns
  • πŸ—£οΈ Tell the community about your experience with playwright-tools
  • πŸ’ Contribute by submitting issues or pull requests

Happy testing and automating tests! πŸš€

jaktestowac.pl Team πŸ’šβ€οΈ

PS. For more resources and updates, follow us on our website and GitHub.


Built with πŸ’šβ€οΈ for the Playwright and testing automation community

GitHub stars GitHub forks GitHub issues