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-ag-grid

v1.0.0

Published

Playwright helpers for interacting with AG Grid

Readme

playwright-ag-grid

Playwright helpers for interacting with and validating AG Grid.

Table of Contents

Installation

npm install playwright-ag-grid --save-dev

Then import the helper in your Playwright tests:

import { createAgGrid, filterOperator, sort } from "playwright-ag-grid";

Usage

Create the Grid Helper

Create a helper instance from the top-level AG Grid locator, including headers and controls.

import { createAgGrid } from "playwright-ag-grid";

const grid = createAgGrid(page.locator("#myGrid"));

Getting Data From the Grid

Use getData() to read the displayed AG Grid rows as structured objects.

const grid = createAgGrid(page.locator("#myGrid"));
const tableData = await grid.getData();

The returned value looks like:

[
  { "Year": "2020", "Make": "Toyota", "Model": "Celica" },
  { "Year": "2020", "Make": "Ford", "Model": "Mondeo" },
  { "Year": "2020", "Make": "Porsche", "Model": "Boxter" },
  { "Year": "2020", "Make": "BMW", "Model": "3-series" },
  { "Year": "2020", "Make": "Mercedes", "Model": "GLC300" }
]

Getting Select Row Data

To only return certain columns, pass onlyColumns:

const grid = createAgGrid(page.locator("#myGrid"));
const tableData = await grid.getData({ onlyColumns: ["Year", "Make"] });

You can also request the raw header/row arrays instead of mapped objects:

const grid = createAgGrid(page.locator("#myGrid"));
const tableData = await grid.getData({ valuesArray: true });

Editing Grid Cells

Playwright does not expose AG Grid cells as Cypress-style command subjects, so the package provides getCellLocator() for targeted cell interaction.

const grid = createAgGrid(page.locator("#myGrid2"));

await grid.filterTextFloating({
  searchCriteria: {
    columnName: "Make",
    filterValue: "Porsche",
    operator: filterOperator.equals,
  },
  hasApplyButton: true,
});

const priceCell = await grid.getCellLocator(
  { Make: "Porsche", Price: "72000" },
  "Price"
);

await priceCell.dblclick();
await priceCell.locator("input").fill("66000");
await priceCell.locator("input").press("Enter");

Sorting Columns

Use sortColumn(columnName, sortDirection):

const grid = createAgGrid(page.locator("#myGrid"));
await grid.sortColumn("Model", "descending");

You can also use the exported enum values:

await grid.sortColumn("Model", sort.ascending);

Pinning Columns

Use pinColumn(columnName, pin) where pin is "left", "right", or null.

const grid = createAgGrid(page.locator("#myGrid"));

await grid.pinColumn("Model", "left");
await grid.pinColumn("Model", "right");
await grid.pinColumn("Model", null);

Filter Options

The filtering commands accept an options object shaped like:

{
  searchCriteria: {
    columnName: string;
    filterValue: string;
    operator?: string;
    searchInputIndex?: number;
    operatorIndex?: number;
    isMultiFilter?: boolean;
  } | Array<{
    columnName: string;
    filterValue: string;
    operator?: string;
    searchInputIndex?: number;
    operatorIndex?: number;
    isMultiFilter?: boolean;
  }>;
  hasApplyButton?: boolean;
  noMenuTabs?: boolean;
  selectAllLocaleText?: string;
}

Option notes:

  • searchCriteria.columnName: column to filter.
  • searchCriteria.filterValue: value to type or select.
  • searchCriteria.operator: optional AG Grid operator text such as Equals, Contains, or Between.
  • searchCriteria.searchInputIndex: optional input index when multiple visible inputs exist.
  • searchCriteria.operatorIndex: optional operator picker index when multiple visible operators exist.
  • searchCriteria.isMultiFilter: optional flag for floating filters using checkbox values rather than free-form text.
  • hasApplyButton: use true when the filter UI has an explicit Apply button.
  • noMenuTabs: use true for grids that render a menu list instead of filter tabs.
  • selectAllLocaleText: localized text for the checkbox filter's Select All entry.

Filter by Text - Column Menu

Use filterTextMenu(options) to filter via the column menu:

const grid = createAgGrid(page.locator("#myGrid"));

await grid.filterTextMenu({
  searchCriteria: [
    {
      columnName: "Model",
      filterValue: "GLC300",
      operator: filterOperator.equals,
    },
    {
      columnName: "Make",
      filterValue: "Mercedes",
      operator: filterOperator.equals,
    },
  ],
  hasApplyButton: true,
});

Filter by Text - Floating Filter

Use filterTextFloating(options) to filter via a column's floating filter:

const grid = createAgGrid(page.locator("#myGrid"));

await grid.filterTextFloating({
  searchCriteria: {
    columnName: "Make",
    filterValue: "Ford",
  },
  hasApplyButton: true,
});

For multiple conditions in the same floating filter:

await grid.filterTextFloating({
  searchCriteria: {
    columnName: "Make",
    filterValue: "B",
    searchInputIndex: 0,
  },
  hasApplyButton: true,
});

await grid.filterTextFloating({
  searchCriteria: {
    columnName: "Make",
    filterValue: "MW",
    searchInputIndex: 1,
  },
  hasApplyButton: true,
});

For Between, pass two entries for the same column:

await grid.filterTextFloating({
  searchCriteria: [
    {
      columnName: "Year",
      filterValue: "1990",
      operator: filterOperator.inRange,
    },
    {
      columnName: "Year",
      filterValue: "2011",
      operator: filterOperator.inRange,
    },
  ],
  hasApplyButton: true,
});

Filter by Checkbox - Column Menu

Use filterCheckboxMenu(options) to filter by checkbox values from the column menu:

const grid = createAgGrid(page.locator("#myGrid"));

await grid.filterCheckboxMenu({
  searchCriteria: {
    columnName: "Model",
    filterValue: "2002",
  },
  hasApplyButton: true,
});

Multiple checkbox values:

await grid.filterCheckboxMenu({
  searchCriteria: [
    { columnName: "Model", filterValue: "2002" },
    { columnName: "Model", filterValue: "3-series" },
  ],
  hasApplyButton: true,
});

Filtering - Localization and Internationalization

When filtering by checkbox, the helper first deselects the Select All entry so only the requested values remain selected. For localized grids, pass the localized Select All text:

await grid.filterCheckboxMenu({
  searchCriteria: {
    columnName: "Model",
    filterValue: "2002",
  },
  selectAllLocaleText: "Tout Sélectionner",
  hasApplyButton: true,
});

Add or Remove Columns

Use toggleColumnFromSideBar(columnName, doRemove) to toggle columns from the sidebar:

const grid = createAgGrid(page.locator("#myGrid"));

await grid.toggleColumnFromSideBar("Year", true);
await grid.toggleColumnFromSideBar("Year", false);

Validation Examples

Unlike the Cypress package, the Playwright package does not currently register assertion helpers. The intended pattern is to use await grid.getData() together with Playwright's expect.

Validate Paginated Table

import { expect } from "@playwright/test";
import { createAgGrid } from "playwright-ag-grid";

const expectedPaginatedTableData = [
  [
    { Year: "2020", Make: "Toyota", Model: "Celica" },
    { Year: "2020", Make: "Ford", Model: "Mondeo" },
  ],
  [
    { Year: "2020", Make: "Honda", Model: "Civic" },
    { Year: "2020", Make: "Honda", Model: "Accord" },
  ],
];

const grid = createAgGrid(page.locator("#myGrid"));

for (const expectedPage of expectedPaginatedTableData) {
  await expect(await grid.getData({ onlyColumns: ["Year", "Make", "Model"] }))
    .toEqual(expectedPage);
  await page.locator("#myGrid .ag-icon-next").click();
}

Validate Table in the Exact Order

import { expect } from "@playwright/test";

const grid = createAgGrid(page.locator("#myGrid"));
const actualTableData = await grid.getData();

await expect(actualTableData).toEqual(expectedTableData);

Validate Subset of Table Data

import { expect } from "@playwright/test";

const grid = createAgGrid(page.locator("#myGrid"));
const actualTableData = await grid.getData({ onlyColumns: ["Year", "Make", "Model"] });

for (const expectedRow of expectedTableData) {
  expect(actualTableData).toContainEqual(expectedRow);
}

Validate Empty Grid

import { expect } from "@playwright/test";

const grid = createAgGrid(page.locator("#myGrid"));
const actualTableData = await grid.getData();

await expect(actualTableData).toEqual([]);

Limitations

  • Validation helpers are not yet packaged as Playwright-specific assertion methods; use Playwright expect with getData().
  • getCellLocator() is the supported element-interaction path; there is not currently a getAgGridElements()-style API returning live DOM element maps.
  • Unlimited scrolling grids are not fully supported when data is outside the rendered DOM.
  • Data outside the current rendered viewport is not available until AG Grid renders it into the DOM.