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.

`cy.get` does not work with IDs that use characters other than [0-9a-zA-Z\-]+

See original GitHub issue

Current behavior:

Running something like cy.get('#Configuration/Setup/TextField.id') yields an error despite being a valid HTML5 ID. Per spec, HTML5 IDs

  • must contain at least one character
  • must not contain any space characters

Instead, when using an ID with characters like / or ., an error gets thrown:

Error: Syntax error, unrecognized expression: #Configuration/Setup/TextField.id

Desired behavior:

IDs with valid characters such as / or . should work.

Steps to reproduce:

Write a spec that accesses an ID formatted as described above, for example: cy.get('#Configuration/Setup/TextField.id').

Versions

Cypress 3.0.1 Chrome Version 67.0.3396.87 (Official Build) (64-bit) Windows 10 64bit

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:21 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
aepplerplangridcommented, May 10, 2019

Hey there! haven’t seen any updates in this in a while, mind if I ask what’s the status of the fix?

2reactions
jennifer-shehanecommented, Jun 25, 2018

Yes, this is a bug. The ID above is fine as defined in spec: https://www.w3.org/TR/html50/dom.html#the-id-attribute

This error is being thrown from Sizzle, and likely was fixed in a later version of jQuery, but we are on an earlier version - version 2.2.4. Pull request to update jQuery: https://github.com/cypress-io/cypress/pull/1229

Read more comments on GitHub >

github_iconTop Results From Across the Web

get
Get one or more DOM elements by selector or alias. The querying behavior of this command is similar to how $(...) works in...
Read more >
Best Practices
Here are potential solutions to alleviate these problems: Use another platform that you control to log in with username and password via cy.origin()...
Read more >
Using Cypress
How do I use special characters with cy.get()?; Can I use Cypress to test charts and graphs? Why doesn't the instanceof Event work?...
Read more >
not
not () yields the new DOM element(s) it found. .not() is a query, and it is safe to chain further commands. Examples. Selector....
Read more >
type
It is unsafe to chain further commands that rely on the subject after .type(). ... cy.get('#code-input') // will not escape { } characters...
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