cypress: `cy.get` does not work with IDs that use characters other than [0-9a-zA-Z\-]+
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
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 21 (8 by maintainers)
Hey there! haven’t seen any updates in this in a while, mind if I ask what’s the status of the fix?
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
@sainthkh
Things cannot change just because a spec is a Working Draft. This particular API has been implemented by all still developed browser engines for a long time (Edge was an exception but the old engine is dead now) so changing it right now in a meaningful way is very likely not Web-compatible.