playwright-magic-utils
v1.0.81
Published
Reusable Playwright utility functions for clean and scalable test automation.
Downloads
142
Maintainers
Readme
Why Choose Playwright Ultimate Utils?
✔️ Built for modern frameworks — optimized for Playwright & Cucumber integration
✔️ Minimal boilerplate — fast implementation & robust abstractions
✔️ Best practices included — error handling, logging, and enhanced stability
Installation
Install via npm:
npm install playwright-ultimate-utilsHow to Access Utility Functions
Simply import the package in your page classes or step definitions:
import * as utils from 'playwright-ultimate-utils';🧰 Core Utility Functions
| Function | Signature | Description |
|------------------------|---------------------------------------------------|-----------------------------------------------------------|
| clickEleByText | (text: string) | Clicks the first visible element with exact text. |
| fillInput | (selector: string, value: string) | Fills the input field with the given value. |
| scrollTo | (selector: string) | Scrolls to the specified DOM element. |
| assertElementText | (selector: string, expectedText: string) | Asserts that the element's text matches exactly. |
| isVisible | (selector: string) | Returns true if the element is visible. |
| getText | (selector: string) | Returns the visible text content of the element. |
| getCookies | () | Retrieves all current cookies. |
| setLocalStorage | (key: string, value: string) | Sets a localStorage value in the browser context. |
| clearSessionStorage | () | Clears the sessionStorage completely. |
| waitForDownload | () | Waits for a download event triggered by user action. |
| handleDialog | (action: 'accept' \| 'dismiss') | Automatically handles alert, confirm, or prompt dialogs. |
| getPerformanceMetrics| () | Retrieves performance-related metrics from the page. |
