How to HIGHLIGHT text with Cypress
Christine Pinto

Christine Pinto @christinepinto

About: Proven ISTQB agile certified testing expert with over 18 years in tech, transitioning into the realm of AI within test automation.

Location:
Berlin
Joined:
Aug 3, 2019

How to HIGHLIGHT text with Cypress

Publish Date: Jul 22 '21
0 0

I recently wrote automated UI tests for a text editor application. One of the most important functions was to format text in different ways (e.g. text styles or text alignments). My biggest issue was to figure out how to highlight🖍️ text with Cypress in order to change the formatting of that text.

This feature is an open Github issue in the Cypress repository. I tried out several of their solutions and this is the one which worked best for me:

// Highlight text in the sectionArea
cy.get(sectionArea).realPress(["Shift","ArrowLeft","ArrowLeft"]);
Enter fullscreen mode Exit fullscreen mode

I used the command realPress() from Cypress real events to simulate the highlighting of text via the keyboard⌨️. This was the easiest solution as I have already used other commands from Cypress real events to solve other issues.

Comments 0 total

    Add comment