`cy.get` does not work with IDs that use characters other than [0-9a-zA-Z\-]+
See original GitHub issueCurrent 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:
- Created 5 years ago
- Reactions:3
- Comments:21 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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