Skip to content

[BUG] Text selector doesn't match by combined innerText #2089

@ingvar-nikiforov

Description

@ingvar-nikiforov

Context:

  • Playwright Version: 0.16.0
  • Operating System: Mac
  • Node version: v13.11.0
  • Browser: All

Code Snippet

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch()
  const context = await browser.newContext()
  const page = await context.newPage()

  await page.setContent(`
<div class="wrapper">
  <div>
    <span>Should</span>
  </div>
  <div>
    <span>match</span>
  </div>
</div>`)

  const elementByClass = await page.$('.wrapper')
  const innerText = await elementByClass.innerText()
  console.log('Inner Text matches regex:', /Should.*match/is.test(innerText))

  const elementByText = await page.$('text=/Should.*match/is')
  console.log('element not found:', elementByText === null)

  await browser.close()
})()

Output

Inner Text matches regex: true
element not found: true

Describe the bug
Since regex matches innerText of .wrapper element I expect it to be matched by selector.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions