Ask questionsSelect / highlight text

Current behavior:

I'm having a hard time creating a text selection. Things I've tried:

  • document.createRange() and window.getSelection()
  • Using cy.trigger to simulate a cursor drag over the paragraph.
  • Using dblclick on the paragraph.

Desired behavior:

Test highlighting text.

Steps to reproduce:

I can provide sample code for the approaches I tried, but I'll hold off for now in case there's a completely different known way of doing this.


Cypress 3.1.1, Chrome 70.0.3538.102


Answer questions Anahkiasen

Yeah I used this Gist successfully on a selection-heavy project test suite and encountered no real issue, I'd be fine if this was the code used for official support despite its potential limitations, it's still better than no support


Related questions

CypressError: Timed out retrying: Expected to find element: '#Login.Submit', but never found it. hot 7
Login through Azure AD account. hot 3
Cypress says script error thrown in cross origin script - do not know why hot 3
cy.clearCookies should clear *ALL* cookies of all domains hot 3
cy.request with failOnStatusCode: false not working hot 3
Can i make a mysql connection in cypress ? hot 3
Launch Cypress with Chrome "Incognito" using --incognito flag hot 2
Cypress should clear indexeddb state between test runs hot 2
TS error: Option 'sourceMap' cannot be specified with option 'inlineSourceMap' - cypress hot 2
3.5.0-3.6.1 regression screenshot on element can be out of bounds hot 2
Login through Azure AD account. hot 2
Send a PKI from the client to the server hot 2
cy.wait() always gives a timeout error: No request ever occurred. hot 2
Cypress return 'Whoops, there is no test to run' after submiting an iframe hot 2
Github User Rank List