kpmck / cypress-ag-grid

Cypress plugin for interacting with ag grid
30 stars 17 forks source link

Merge 2.0.0-beta into master #31

Closed kpmck closed 2 years ago

kpmck commented 2 years ago

This PR enables getAgGridElements() which allows us to retrieve the actual cell elements from the AG grid.

Getting Elements From the Grid

To get the Ag Grid data as elements (if you want to interact with the cells themselves), you must chain .getAgGridElements() after the cy.get() command for the topmost level of the grid, including controls and headers (see selected DOM element in above image).

    cy.get(agGridSelector)
      .getAgGridElements()
      .then((tableElements) => {
        const porscheRow = tableElements.find(
          (row) => row.Price.innerText === "72000"
        );
        const priceCell = porscheRow.Price;
        cy.wrap(priceCell).dblclick().type("66000{enter}");
      });

The above example will grab the table as elements, finds the row whose Price equals 72000. It then gets the Price cell for that row, double clicks on it to enable an editable input, and changes the value of the cell.