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] Xpath starting with . not picked up by xpath heuristic #2197

Closed
Georgegriff opened this issue May 12, 2020 · 2 comments · Fixed by #2213
Closed

[BUG] Xpath starting with . not picked up by xpath heuristic #2197

Georgegriff opened this issue May 12, 2020 · 2 comments · Fixed by #2213

Comments

@Georgegriff
Copy link
Contributor

Context:

  • Playwright Version: 1.0.1
  • Operating System: All
  • Node version: 12.x
  • Browser:All

Code Snippet

Help us help you! Put down a short code snippet that illustrates your bug and
that we can run and debug locally. For example:

    const browser = await playwright.chromium.launch({ headless: false})
    const context = await browser.newContext({ viewport: null })
    const page = await context.newPage()

    await page.goto('chrome://downloads')

    const element = await page.waitForSelector('.//div', {timeout: 3000})

Describe the bug
It tries to use the css locator strategy instead.
I'm guessing this might be a hard problem to solve given the semantics.

image

As you can see this is a valid xpath
image

aslushnikov added a commit to aslushnikov/playwright that referenced this issue May 12, 2020
The "working with selectors" section elaborates on rules that we use
to parse selectors.

References microsoft#2197
@aslushnikov
Copy link
Collaborator

@Georgegriff Even though we can hot-fix this particular case, the general problem of differentiating between xpath and css is not an easy one and looks like a slippery slope to me. So we'd rather be conservative and stick with a simple-and-clear rule we have today:

only those selectors that start with // are treated as xpath.

Honestly, it wasn't that easy to find the rules for our selectors in the docs - I've updated docs to have clear references (#2213). Hopefully it'll make life easier.

aslushnikov added a commit that referenced this issue May 12, 2020
…ts (#2213)

The "working with selectors" section elaborates on rules that we use
to parse selectors.

Fixes #2197
@Georgegriff
Copy link
Contributor Author

That's fair, in the framework this came from (CodeceptJS) they have a different heuristic for figuring out xpath so can fix over there rather than here for our user cases thanks for responding

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.

2 participants