A comprehensive collection of utilities for Playwright testing that simplify common testing patterns and enhance your automation workflow.
- π‘οΈ 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
npm install playwright-tools
Peer Dependency: This package requires @playwright/test
to be installed in your project.
npm install @playwright/test
import { safeClick, safeFill, elementExists } from "playwright-tools";
// Safe element interactions
await safeClick(page.locator("#submit-button"));
await safeFill(page.locator("#username"), "john.doe@example.com");
// Check element existence without throwing
const exists = await elementExists(page.locator("#optional-element"));
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";
π Complete documentation is available in the docs directory:
- π Main Documentation - Overview and navigation
- π― Element Interactions - Safe clicks, fills, and form handling
- π Element Queries - Existence checks and bulk operations
- π Navigation - Safe navigation and page management
- β¨οΈ Advanced Interactions - File uploads, drag & drop, keyboard shortcuts
- π Locator Decorator - Extend Playwright locators with custom methods
- πΈ Screenshots - Timestamped and debug screenshots
- π Assertions - Enhanced assertion helpers
- β³ Waiting - Smart waiting strategies
- π Retry - Exponential backoff retry logic
- π― Accessibility - ARIA and accessibility testing
- πΎ Storage - localStorage and sessionStorage management
- π Network - Network request monitoring and waiting
- π Network Monitoring - Advanced network analysis
- π¬ Dialogs - Modal and popup handling
- π Tables - Table data extraction and validation
- π§ Page Objects - Reusable page object patterns
- β‘ Performance - Performance measurement utilities
- π οΈ Error Handling - Error handling patterns
- β‘ Test Utils - Test filtering and dispatching
- π Examples - Practical usage examples
- π Migration Guide - From raw Playwright to playwright-tools
- π οΈ Best Practices - Recommended patterns and configurations
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: "john@example.com" },
]);
await safeClick(page.locator("#submit"));
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"),
]);
import { waitForNetworkRequest } from "playwright-tools";
// Wait for specific API call
const response = await waitForNetworkRequest(page, "/api/users", {
method: "GET",
status: 200,
timeout: 10000,
});
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 }
);
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.
- 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
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
- π Full Documentation
- π Examples
- π Migration Guide
- π οΈ Best Practices
- π Issues & Bug Reports
- π¬ Discord Community
- GAD (GUI API Demo) - Our free application designed specifically for automation practice
- Free Playwright Resources - Comprehensive Polish learning materials
- Playwright Basics - YouTube series (Polish)
- Playwright Elements - Advanced concepts (Polish)
- Playwright MCP - MCP course (Polish)
- Discord Community - First Polish Playwright community!
- Playwright Info - First and only Polish Playwright blog
- VS Code Extensions - Our free Playwright plugins
- Playwright Documentation - Official documentation
- Playwright GitHub - Source code and issues
Feel free to reach out to us:
- π Website: jaktestowac.pl
- πΌ LinkedIn: jaktestowac.pl
- π¬ Discord: Polish Playwright Community
- π§ Support: Check our website for contact details
- π Issues: GitHub Issues
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