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-helper-utils/generic-utils

v1.1.1

Published

This package provides a collection of utility functions for Playwright, a powerful end-to-end testing framework. These utilities are designed to simplify common tasks and enhance the efficiency of your Playwright test scripts.

Downloads

355

Readme

@playwright-helper-utils/generic-utils

A collection of utility functions for Playwright to simplify common tasks and enhance the efficiency of your end-to-end test scripts.

Installation

npm install @playwright-helper-utils/generic-utils

Peer Dependency: Requires @playwright/test >= 1.0.0

Usage

import {
  clickSelector,
  fillTextInput,
  waitForSelectorToEnable,
  delay,
} from '@playwright-helper-utils/generic-utils';

API Reference

Core Element Interactions

| Function | Description | |---|---| | clickSelector(locatable, selector) | Waits for the element to become visible, then clicks it. | | forceClick(locatable, selector, doubleClick?) | Force-clicks an element, bypassing actionability checks. Optionally double-clicks. | | fillTextInput(locatable, selector, text, options) | Fills a text input field. Set { clear: true } to clear existing content first. | | fillLargeText(locatable, selector, text) | Fills large text by setting the element value directly via JS evaluation. | | waitForSelectorToEnable(locatable, selector) | Waits for the element to become visible (up to 180s). | | waitForSelectorToDisable(locatable, selector) | Waits for the element to become hidden (up to 180s). |

Element Data Retrieval

| Function | Description | |---|---| | getElementInnerText(locatable, selector) | Returns the inner text of the first matching element. | | getElementInnerTextByPosition(locatable, selector, position) | Returns the inner text of the element at a specific zero-based index. | | getAttributeValue(locatable, selector, attributeName) | Returns the value of an HTML attribute from the first matching element. | | getElementPropertyValue(locatable, selector, property) | Returns the computed CSS property value of the first matching element. | | getElementPropertyValueUsingXPath(page, xpath, property) | Returns the computed CSS property value of an element located via XPath. |

Navigation & Frame Handling

| Function | Description | |---|---| | navigateToNewTab(page, selector) | Clicks an element that opens a new tab, waits for it to load, and returns the new Page. | | getFrameByName(page, frameName) | Retrieves a child frame by its name attribute. | | getElementTextValueFromFrame(page, selector, frameName) | Gets the .value of an input/textarea within a named frame. | | uploadFile(page, scope, selector, filePath) | Uploads a file via the file chooser dialog triggered by clicking the specified element. |

Element Layout & Visual Validation

| Function | Description | |---|---| | getElementBoundingBoxValue(locatable, selector, position?) | Returns [x, y, height, width] of an element's bounding box. | | getElementOrientation(locatable, selector) | Returns 'Portrait' or 'Landscape' based on the element's dimensions. | | checkOverlap(locatable, selector1, selector2) | Returns true if two elements' bounding boxes intersect. | | verifyScrollBarPresence(locatable, selector, verticalScroll?) | Returns true if a vertical (default) or horizontal scroll bar is present. |

Canvas Operations

| Function | Description | |---|---| | drawLineInCanvas(element) | Draws a horizontal line on a canvas from (50, 50) to (200, 50). | | getCanvasImageData(element) | Returns the RGBA pixel data array for the drawn line region. |

Network & Browser Control

| Function | Description | |---|---| | blockNetwork(page) | Blocks all network requests by emulating offline conditions via CDP. |

Utility & Helper Functions

| Function | Description | |---|---| | generateUniqueName(prefix) | Generates a unique name: {prefix}_Playwright_{timestamp}. | | delay(milliseconds) | Promise-based delay (replacement for deprecated waitForTimeout). | | parseJsonFromString(input) | Extracts and parses a JSON object from a raw string, sanitizing smart quotes. | | convertPxToPt(px) | Converts a pixel value string to points (px × 0.75). | | getFirstMatchingXPathNode(page, xpath) | Returns the first DOM node matching an XPath expression, or undefined. | | readTextFromFile(filePath) | Reads a text file and returns its UTF-8 content. | | executeBatchFile(batchFilePath) | Executes a batch file synchronously. |


Type: Locatable

Most functions accept a locatable parameter, which can be any of:

type Locatable = Page | Locator | FrameLocator | Frame;

This allows you to scope element lookups to the full page, a specific frame, or a nested locator.

License

ISC