Autify Nexus contains native functionality to assert on the text content of an element, and we recommend that you use that functionality as often as possible.
In the event that it is not possible to use a standard assertion, the Playwright code snippet below can be used as a workaround.
How to set it up
Get the CSS selector of the target element, and make a note of it.
Insert a Playwright code step into the scenario and copy and paste the following snippet into the Playwright code step.
// TODO: Please replace the selector with the one for the target element
const selector = "<TODO: REPLACE SELECTOR>";
// Get the text content of the element
// If the element is not found, the test will fail here
const text = await page.locator(selector).first().textContent();
return text;
Replace
<TODO: REPLACE SELECTOR>
in the snippet above with the CSS selector noted in step 1.