I want to do some text selection on a text document as shown in the image. The words "automatically translates those" are highlighted using right click and dragging from start to end. I want to perform the similar operation using cypress.
Can someone help me with it?
I have tried trigger mouseover using cypress but that did not seem to work.
2
Answers
You can’t, that’s outside the scope of cypress. You can customize it using the CSS style containing the things you want to highlight.
There is a range object in javascript that can allow you to implement it.
Roughly speaking, this is how it goes:
This HTML:
using this test
Note the text you get back has spaces between the letters, so that may cause you problems in a more complex example that already contains spaces. But you can step through the string and take every second character,