Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

auto-heal-utility

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auto-heal-utility

A Playwright utility for auto-healing broken locators.

latest
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

Auto-Healer Utility for Playwright

This utility provides a way to auto-heal broken locators in your Playwright tests. It works by logging locator failures and then using that data to intelligently select the best locator from a list of alternatives.

Installation

npm install auto-healer-utility

Usage

import { WaitHelper } from 'auto-healer-utility';
import { test } from '@playwright/test';

test('my test', async ({ page }) => {
  const waitHelper = new WaitHelper(page);

  // Use the waitHelper to interact with elements
  await waitHelper.waitForElementAndClick([page.locator('#button1'), page.locator('#button2')], {
    feature: 'my feature',
    scenario: 'my scenario',
    step: 'click button',
  });
});

How it Works

The WaitHelper class is the main entry point for the utility. It takes a Playwright Page object in its constructor. The waitForElementAndClick and waitForElementAndFill methods take an array of locators and a metadata object. The metadata object is used to log information about the test that is running.

The AutoHeal class is responsible for the core auto-healing logic. It works by:

  • Logging failures: When a locator fails, the AutoHeal class logs the failure to a file. The log entry includes the locator, the reason for the failure, and the metadata.
  • Analyzing logs: The AutoHeal class analyzes the log file to determine which locators are the most reliable. It does this by counting the number of times each locator has failed.
  • Selecting the best locator: When you call waitForElementAndClick or waitForElementAndFill, the AutoHeal class selects the best locator from the array of locators that you provide. It does this by selecting the locator that has failed the least number of times.

Configuration

The AutoHeal class can be configured with the following options:

  • timeout: The timeout in milliseconds to wait for a locator to be attached to the DOM. Defaults to 60 seconds.
  • logFile: The path to the log file. Defaults to logs/locator_failures.log.

Keywords

playwright

FAQs

Package last updated on 13 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts