How can I find an element in Puppeteer or Playwright using part of the element title?

Viewed 1606

I need to test when this element appears on the DOM. I want to use the 'title' for that. The NBA part stays always the same, the other part '0c381941-0' is dynamic.

I tried

await page.waitForSelector('.identifier.identifier-group[title=`NBA ${idVariable}`)

but those backticks aren't acceptable there.

Any clue?

    <dl class="identifier identifier-group" title="NBA 0c381941-0">
    <dl class="player-identifier-label identifier" title="NHI 0c381941-0">
    <dt><span>NBA</span></dt>
    <dd><span>0c381941-0</span></dd>
    </dl>
    </dl>
1 Answers

await page.waitForSelector(`.patient-identifier-label.identifier[title=NBA ${playerId}`)

Related