Search code examples
javascripttddintegration-testinge2e-testingcypress

How to select text using cypress


I'm looking to test a text editor like https://github.com/brijeshb42/medium-draft using Cypress. But I can't find a way to select text using it. Does anyone have a clue on how to do that?

I'd have to select a specific text range in order for the test to be effective.


Solution

  • The commented answer above was the clue I needed, but it needs a couple tweaks (at least as of the version I'm using: v3.1.5). The link has all the info, but the answer should be as follows

    cy.type('{selectall}')
    

    Note that it's ".type()" instead of ".text()" and the escape sequence is quoted...