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.
Cypress can validate the text on an element with the help of jQuery text() method. This method shall help us to fetch the text content on the selected element. We can also put assertions on the text content of the element. cy.
Browser Automation with Cypress and Gherkin 2022The command select is used to work with static dropdown. In the html code, a dropdown has a select tag and the dropdown elements are represented by option tagname.
To select an element by class you need to use . prefix and to select an element by its it, you should prefix id with # . The most common attribute you might find on your page would be a placeholder for an input or even a test-id where your selector starts and ends with square brackets.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With