I want to check if the text QUEUED
appears on a website. I tried the following commands
await expect(page1).toContainText('[QUEUED]');
await expect(page1.locator('span')).toContainText('[QUEUED]');
but in the first example it says a "locator" is expected, and for the second one it says
Error: strict mode violation: "span" resolved to 108 elements:
I am not interested in the exact element, I just want to check if the text QUEUED
appears at least once on the page.
I also tried to select the exact element which in the HTML DOM looks like
<span data-v-729cd282="" class="">QUEUED</span>
using the expression
await expect(page1.locator('(//span[@data-v-729cd282])[6]')).toHaveText('[QUEUED]');
but here I also get an error
waiting for selector "(//span[@data-v-729cd282])[6]"
So how to do this right?
element
is aLocator@internal:text="QUEUED"i
, which therefore is neverundefined
-- it's always true. – Posterity