cypress-io / cypress-example-recipes

Various recipes for testing common scenarios with Cypress
https://on.cypress.io/examples
3.42k stars 1.34k forks source link

Fix for clipboard recipe #898

Open Amy-B-Tradition opened 1 week ago

Amy-B-Tradition commented 1 week ago

In the permissions spec for the clipboard, I saw a comment "how can we paste in chrome".

This seems to work for me

cy.fixture(csvPath).then(async (textToPaste) => {
      cy.window().its('navigator.clipboard')
        .then(clip => clip.writeText(textToPaste))
      cy.get('[data-testid="my-ag-grid"]')
        .find('.ag-cell.ag-column-first')
        .first()
        .as('firstCell')
        .click()
      cy.get('@firstCell').type('{ctrl}v')
      cy.get('@firstCell').contains('myText')
    })