typescriptautomated-testscypressag-gridlost-focus

Cypress - AG-Grid table: Command type() loosing focus of the Cell


I have the following problem:

I want to enter a value into the cell with 'type()'. My guess is that the focus on this cell is lost when entering the value.

Due to the fact that the focus is lost on each letter and the command 'type()' probably clicks back into the cell, the last letter is highlighted and replaced with the next letter. The result looks like this: T e s t

The attempt with the commands 'wait()' and 'focus()' failed.

Maybe there is a possibility to slow down the automated entering of the values

I am curious about your opinion and experiences.

Thanks a lot

AG-Grid Cell Code:

<div comp-id="1" class="ag-cell ag-cell-normal-height ag-cell-value ag-cell-inline-editing ag-cell-range-selected ag-cell-range-selected-1 ag-cell-range-single-cell" tabindex="-1" role="gridcell" aria-colindex="1" col-id="column" unselectable="on" style="left: 0px; width: 150px;">t</div>

Screenshot of Cell: enter image description here

Cypress Command:

cy.get('div[row-id="1553c463-0c87-4cc4-a672-89090c6f2cb9"]').should('exist').find('div[col-id="column"]').should('be.visible').click().type('Test{enter}');

Solution

  • You asked about slowing down the values.

    Did you look at the docs Aruments - options

    delay - Delay after each keypress

    .type('Test{enter}', {delay:100})
    

    Another way to try is realType().

    It takes a different approach internally to Cypress .type()

    cy.get('div[row-id="1553c463-0c87-4cc4-a672-89090c6f2cb9"] div[col-id="column"]')
      .should('be.visible')
      .focus();
    cy.realType("some text {enter}"); // type into focused field