Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testcafe should support IDs starting with a number #1899

Closed
zoejobson opened this issue Oct 20, 2017 · 2 comments
Closed

testcafe should support IDs starting with a number #1899

zoejobson opened this issue Oct 20, 2017 · 2 comments
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot.

Comments

@zoejobson
Copy link

Are you requesting a feature or reporting a bug?

feature/bug (testCafe is out of date with current javascript)

What is the current behavior?

the most recent version of javascript supports IDs which start with a number eg Selector('#1_AccountCode'), testcafe doesn't appear to
it errors telling e that the id doesn't exist in the dome, but if I use a selector Selector('[id='1_accountCode']') then it works fine

What is the expected behavior?

numbered IDs should be supported with the # operator

How would you reproduce the current behavior (if this is a bug)?

create a page with numbered IDs and try to select them with # selectors

Specify your

  • operating system: windows 7
  • testcafe version: 0.18.0
  • node.js version: 6.11.4
@AlexanderMoskovkin
Copy link
Contributor

Hi @zoejobson,

We just call the document.querySelectorAll function in the browser to find elements by a selector string. So, if you type document.querySelectorAll('#1_input') into a browser console the error is not a valid selector is appeared.

Such ids are valid according to the HTML5 specification. But they are not valid according to the CSS specification:

they cannot start with a digit, two hyphens, or a hyphen followed by a digit

E.g. you can't create a css style like:

#1_AccountCode {
    display: none;
}

I suppose that's why the querySelectorAll function works in this way in browsers.

But you can easily workaround it by using the withAttribute method:

Selector('input').withAttribute('id', '1_AccountCode')

@lock
Copy link

lock bot commented Mar 28, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot.
Projects
None yet
Development

No branches or pull requests

2 participants