I use the Puppeteer framework to automize tests. I need to find an element as per a text:
await page.focus(//span[contains(text(), 'Name')]])
<span class="some_placeholder">Name</span>
<span class="some_placeholder">Phone Number</span>
But in this case the following error occurs:
Evaluation failed: DOMException: Failed to execute 'querySelector' on Document '' is not a valid selector..
span[class='name']
finds some elements successfully but only one element is needed.
focus()
accepts a CSS selector and does not accept contains()
or text()
methods.
How should I code the search condition correctly?