kpmck / cypress-ag-grid

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

getAgGridData is not returning the right data #24

Closed fddayan closed 2 years ago

fddayan commented 2 years ago

I'm calling getAgGridData

 cy.get('.ag-root-wrapper').getAgGridData().then(actualTableData => {
      console.log(actualTableData)
    })

and I'm getting

[
    {},
    {},
    {}
]

I do see rows in the table. I'm using the react wrapper for ag table.

kpmck commented 2 years ago

Hi @fddayan - would you be able to point me to a reproducible solution or an example of your AG grid implementation, please? Or if you can provide me with the DOM of your AG grid, that can help me debug this issue for you.

rashmipatil9503 commented 2 years ago

I am facing the same issue, getAgGridData() funtion returns empty array.

cy.get(agGridSelector,{timeout: 10000}).getAgGridData().then((actualTableData) => {
      console.log(actualTableData)
    });

Output:

[]
length: 0
kpmck commented 2 years ago

Hi @rashmipatil9503 can you provide me an example of a grid that this is occurring on and your exact agGridSelector please? Unfortunately I will be unable to assist without a reproducible solution or more information on the DOM structure of your AG grid.

rashmipatil9503 commented 2 years ago

HI @kpmck attached is the file for you to reference.

ad-grid-dom.txt

and here is the value of adGridSelector const agGridSelector = ".data-container";

Also, the getAgGridData() funtion gives the desired data when i used if after the agGridColumnFilterCheckboxMenu(). here is the example of the test:

it("able to filter column type designation", () => {
    cy.get(agGridSelector, {
      timeout: 10000,
    }).agGridColumnFilterCheckboxMenu({
      searchCriteria: {
        columnName: "Col1",
        filterValue: "100",
      },
    });
    cy.get(agGridSelector)
      .getAgGridData()
      .then((actualTableData) => {
        console.log(actualTableData);
        cy.get(agGridSelector).agGridValidateRowsExactOrder(
          actualTableData,
          expectedFilterTableData
        );
      });
  });
kpmck commented 2 years ago

@rashmipatil9503 my best guess is you are attempting to get your grid data before it's fully loaded, so then it is showing 0 items in the collected array. Can you try putting the below command before trying to call cy.get(agGridSelector)...?

cy.get('.ag-cell').should('be.visible')

rashmipatil9503 commented 2 years ago

hi again,

Now I get the desired data in the actualTableData array. Thank you for your help. :)

Regards, Rashmi

kpmck commented 2 years ago

Glad to hear that, @rashmipatil9503!

closing this ticket out, but please feel free to reopen if you are still experiencing this, @fddayan.