webdriverio / query-selector-shadow-dom

querySelector that can pierce Shadow DOM roots without knowing the path through nested shadow roots. Useful for automated testing of Web Components. Production use is not advised, this is for test environments/tools such as Web Driver, Playwright, Puppeteer
MIT License
242 stars 25 forks source link

Selectors with whitespace within attribute selector fails to parse properly #31

Closed chriscapaci closed 4 years ago

chriscapaci commented 4 years ago

I'm attempting to use a selector that works with querySelector, but doesn't with the querySelectorDeep function in this package.

meta[name = 'some_name']

Stepping through the code, I eventually get to a point where it's trying to use this as the selector:

'some_name']

And fails at the .matches() call in collectAllElementsDeep with:

Error: Failed to execute 'matches' on 'Element': ''some_name']' is not a valid selector.

If I take the whitespace out it works fine. And like I said above, this same selector works in the browser's querySelector and querySelectorAll functions. So the parsing is incorrect in this package.

Georgegriff commented 4 years ago

Thanks for the issue I'll try to take a look when I find some time, it looks like you have a work around for now

chriscapaci commented 4 years ago

Yeah, I know what's wrong and can just avoid it. But they're accepted by the non-deep function, so I figured you might want it for your deep function as well. Thanks.

Georgegriff commented 4 years ago

Should be fixed in 0.5.0 just released