Skip to content

[BUG] xpath css selector all dont work #13012

@wanghaisheng

Description

@wanghaisheng

Context:

  • Playwright Version: [what Playwright version do you use?]
  • Operating System: [e.g. Windows, Linux or Mac]
  • Node.js version: [e.g. 12.22, 14.6]
  • Browser: [e.g. All, Chromium, Firefox, WebKit]
  • Extra: [any specific details about your environment]

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 {chromium, webkit, firefox} = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const context = await browser.newContext();
  const page = await context.newPage();
  
  // Please include a snippet of HTML that shows an example of the content
  // you are testing.
  await page.setContent(`
    <div>

    </div>
  `);
  // Alternatively, if you are testing a public application, include the URL:
  // await page.goto('https://example.com/')
  
  await page.locator();
})();

Describe the bug

Add any other details about the problem here.

full code here

    const page = await browser.newPage();


    await page.goto('https://www.merchantgenius.io/')
    // console.log(await page.content())
    const yuefen1 =  await page.locator('xpath=//html/body/main/div/div[2]/a')
    console.log('1-',await yuefen1.length)
    const yuefen2 =  await page.locator('div.container > a')
    console.log('2-',await yuefen2.length)

it give me underfined,am i missing something

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions