--- title: "Getting an element's text" slug: "getting-an-elements-text" updated: 2025-09-30T06:20:32Z published: 2025-09-30T06:20:32Z canonical: "helpcenter.autify.com/getting-an-elements-text" --- > ## Documentation Index > Fetch the complete documentation index at: https://helpcenter.autify.com/llms.txt > Use this file to discover all available pages before exploring further. # Getting an element's text [](https://helpcenter.autify.com/docs/en/text-assertions) [](https://helpcenter.autify.com/docs/en/text-assertions) Autify Nexus contains native functionality to [assert on the text content of an element](https://helpcenter.autify.com/docs/how-to-get-an-elements-text-content-for-use-in-a-later-step), 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 1. Get the CSS selector of the target element, and make a note of it. 2. Insert a Playwright code step into the scenario and copy and paste the following snippet into the Playwright code step. ```typescript // TODO: Please replace the selector with the one for the target element const 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; ``` 1. Replace `<TODO: REPLACE SELECTOR>` in the snippet above with the CSS selector noted in step 1.