10
votes

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.

1
What did you try so far? It's always useful to post your current attempt in the question.Richard Matsen
Ref docs there is cy.text({selectall}) which should select all the element's text, then maybe cy.text({selectall}{rightarrow}{rightarrow}) gives you partial selection.Richard Matsen

1 Answers

21
votes

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...