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

[BUG] CSS attribute selector not working with a value with spaces #1996

Closed
thernstig opened this issue Apr 27, 2020 · 4 comments · Fixed by #2007
Closed

[BUG] CSS attribute selector not working with a value with spaces #1996

thernstig opened this issue Apr 27, 2020 · 4 comments · Fixed by #2007

Comments

@thernstig
Copy link
Contributor

Context:

  • Playwright Version: 0.15.0
  • Operating System: Ubuntu 18.04.4

Code Snippet

// test is a real attribute on the <a> tag in this case
await page.waitFor('a[test="Test Monitor"]');

Describe the bug

The above snippet fails with:

Evaluation failed: DOMException: Failed to execute 'querySelectorAll' on 'Document': 'Monitor"]' is not a valid selector.
@mxschmitt
Copy link
Member

I also faced into this issue. My example: await page.click("[placeholder='Select date']")

@dgozman
Copy link
Contributor

dgozman commented Apr 27, 2020

This works for me locally, and on the bots (see the test in #2001). Am I missing something?

@mxschmitt
Copy link
Member

Seems like it doesn't wait if an element with that property is one the page. Not sure if this is expected or not.
Code:

const playwright = require("playwright");

(async () => {
  const browser = await playwright.chromium.launch();
  const page = await browser.newPage();
  setTimeout(async () => {
    await page.setContent(`<input placeholder="Select date"/>`)
  }, 2000)
  await page.click("[placeholder='Select date']")
  await page.screenshot({ path: `example.png` });
  await browser.close();
})();

interactive: https://try.playwright.tech/?s=f9dpl

Error:

Error: Error: Evaluation failed: DOMException: Failed to execute 'querySelectorAll' on 'Document': 'date']' is not a valid selector. at queryShadowInternal (__playwright_evaluation_script__:284:27) at Object.query 
(__playwright_evaluation_script__:265:20) at SelectorEvaluator._querySelectorRecursively 
(__playwright_evaluation_script__:833:51) at SelectorEvaluator.querySelector 
(__playwright_evaluation_script__:828:21) at 
__playwright_evaluation_script__:5:43 at Injected._pollMutation 
(__playwright_evaluation_script__:471:25) at Injected.poll 
(__playwright_evaluation_script__:539:25) at __playwright_evaluation_script__:4:39 at __playwright_evaluation_script__:17:11

@dgozman
Copy link
Contributor

dgozman commented Apr 28, 2020

This is indeed a problem, nice catch! My test was only resolving when the element existed, and never when it was missing 🤦It seems like the deep css selector mishandles quotes, I'll make a fix shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants