question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for {home} and {end} special character sequences

See original GitHub issue

Current behavior:

cy.type('{home}') and cy.type('{end}') are not supported:

CypressError: Special character sequence: '{home}' is not recognized. Available sequences are: {selectall}, {del}, {backspace}, {esc}, {{}, {enter}, {leftarrow}, {uparrow}, {rightarrow}, {downarrow}, {alt}, {option}, {ctrl}, {control}, {meta}, {command}, {cmd}, {shift}
CypressError: Special character sequence: '{end}' is not recognized. Available sequences are: {selectall}, {del}, {backspace}, {esc}, {{}, {enter}, {leftarrow}, {uparrow}, {rightarrow}, {downarrow}, {alt}, {option}, {ctrl}, {control}, {meta}, {command}, {cmd}, {shift}

Desired behavior:

Support the {home} and {end} special character sequences.

Versions

Cypress 3.0.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:11
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jennifer-shehanecommented, Jun 26, 2018

Great suggestion. The code for special characters can be found here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cypress/keyboard.coffee#L11

As a workaround, you should be able to create a custom command for these by triggerering the keyboard events after knowing the keyCode like this:

Cypress.Commands.add('homeKey', {prevSubject: 'element'} (subject, opts) => {
  cy.wrap(subject).trigger('keydown', {
      keyCode: 36,
      which: 36,
      shiftKey: shiftKey,
      ctrlKey: ctrlKey
  });

  return subject
});

Cypress.Commands.add('endKey', {prevSubject: 'element'} (subject, opts) => {
  cy.wrap(subject).trigger('keydown', {
      keyCode: 35,
      which: 35,
      shiftKey: opts.shiftKey,
      ctrlKey: opts.ctrlKey
  });

  return subject
});
0reactions
skorunkacommented, Mar 24, 2019

Great job! Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Special character sequences
Special character sequences. Printable characters, such as “a” or “b”, are defined by simply typing them into a regular expression.
Read more >
about Special Characters - PowerShell | Microsoft Learn
Describes the special character sequences that control how PowerShell interprets the next characters in the sequence.
Read more >
Regular Expression (Regex) Tutorial
Escape Sequences (\char): To match a character having special meaning in regex, you need to use a escape sequence prefix with a backslash...
Read more >
How to type special characters on a Windows 10 PC - The Verge
Click on the icon to switch keyboards. The US International Keyboard gives you two ways to add a special character: Use the right-hand...
Read more >
Special Characters and Quoting - Learning the bash ... - O'Reilly
|, Pipe, 1 ; [, Start character-set wildcard, 1. ] ; ] End character-set wildcard, 1 ; {, Start command block, 7. } ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found