There is an element that loads up after a few seconds the form is submitted(page doesn't reload after submission). I want to assert that this element has some text value in it. Value doesn't matter but there should be some text in the element.
Currently I am asserting it like this -
await expect(await targetPage.locatorToSomeElement.innerText()).toBeTruthy();
OR this -
await expect(targetPage.locatorToSomeElement).toBeTruthy();
targetPage
is class instance of Page Object Model class TargetPage
and
locatorToSomeElement
is locator with value page.getByTestId("some-span-element")
;
Please let me know the best way to achieve this. Please check below points as well.
The first statement seems like a manual assertion? await is inside expect? It's a bad practice? https://playwright.dev/docs/best-practices#use-web-first-assertions
toBeTruthy()
is an assertion that doesn't not auto wait so I believe second statement will always be true?