Skip to main content

Overview

The Check Text step verifies that elements on your page contain (or don’t contain) specific text. It’s your go-to assertion for confirming that content displays correctly, error messages appear when they should, or unwanted text is absent from the page.

When to Use Check Text

Use Check Text when you need to:
  • Verify successful actions: Confirm messages like “Profile updated successfully” or “Item added to cart”
  • Check dynamic content: Validate that user names, order IDs, or calculated values display correctly
  • Test error handling: Ensure error messages appear when expected
  • Confirm data absence: Verify that sensitive information or error messages are NOT showing
  • Validate multi-step workflows: Check that data from earlier steps appears correctly later in your test

How It Works

Check Text finds an element using a CSS selector and reads its visible text content. It then compares that text against what you expect to find (or not find). Unlike checking attributes or values in the HTML, this step looks at the actual text a user would see on the page. You can check for static text, environment variables, or dynamic values you captured earlier in your test. The step supports both positive assertions (“this text should be here”) and negative assertions (“this text should NOT be here”).

Using the Check Text Step

When you add a Check Text step, you’ll configure these elements:

Finding Your Element

Use the element picker to visually select the element containing the text, or enter a CSS selector directly. Make sure your selector targets the element that actually contains the text content - not a parent container or wrapper element.

Specifying Expected Text

Check Text gives you three ways to specify what text you’re looking for: Static Text Type the exact text you expect to see. Great for verifying standard messages, labels, or content that doesn’t change. Environment Variables Reference configuration values using {{VARIABLE_NAME}} syntax. Useful when expected text differs between environments (like server names or URLs). Variables from Previous Steps Toggle “Use variables” to choose from values you captured earlier in your test. This appears when you’ve used steps like Extract Value, Run Python, or API Request. Perfect for verifying that data flows correctly through your application.

Choosing Your Assertion Type

By default, Check Text verifies the element contains your expected text. You can switch this to verify the element does not contain the text - ideal for checking that errors are absent or sensitive data isn’t exposed.

Real-World Examples

Confirming a Success Message

Locator: .success-notification
Expected Text: Your profile has been updated successfully
Assertion: Element has text
Why this works: After a user action, you want to confirm the right feedback appears.

Verifying Dynamic User Data

Step 1: Navigate to profile page

Step 2: Check Text
  Locator: .user-display-name
  Expected Text: {{EXPECTED_USER_NAME}}
  Assertion: Element has text
Why this works: Use environment variables to test with different users across different environments.

Multi-Step Workflow Verification

Step 1: Extract Value
  Locator: .order-confirmation-number
  Variable Name: orderNumber

Step 2: Navigate to order history page

Step 3: Check Text
  Locator: .recent-orders
  Use variables: orderNumber
  Assertion: Element has text
Why this works: Capture a value from one page and verify it appears correctly on another page.

Confirming Error is Absent

Locator: .error-message-container
Expected Text: network timeout
Assertion: Element does not have text
Why this works: After resolving an issue, verify that specific error messages no longer appear.

Validating Calculated Results

Step 1: Fill
  Locator: input[name='quantity']
  Text: 3

Step 2: Click
  Locator: button[type='submit']

Step 3: Check Text
  Locator: .total-price
  Expected Text: $89.97
  Assertion: Element has text
Why this works: Verify that your app correctly calculates and displays computed values.

Best Practices

Write Specific Selectors

  • Target the exact element containing the text: .success-message
  • Avoid overly broad selectors that might match multiple elements: div
  • Use data-testid attributes when available: [data-testid='confirmation-text']

Choose the Right Verification Strategy

  • Use “Element has text” to confirm expected content is present
  • Use “Element does not have text” to verify errors are absent or sensitive data isn’t exposed
  • Consider partial text matching for dynamic content (like timestamps or IDs)

Handle Dynamic Content Carefully

  • Be aware of whitespace and line breaks in text content
  • Account for text formatting (like extra spaces or special characters)
  • For content that loads asynchronously, add a Wait for Element step first

Chain Steps for Comprehensive Testing

Combine Check Text with other steps for robust verification:
  • After a Click, verify the expected result appears
  • After a Fill, confirm the entered data displays correctly
  • Before a Check Text, use Extract Value to capture dynamic data

Troubleshooting

Element Not Found

Symptom: Test fails saying it can’t find the element Solution:
  • Verify the element exists on the page when the step runs
  • Use the element picker to confirm your selector
  • Add a Wait for Element if the content loads dynamically

Text Doesn’t Match

Symptom: Test fails because text doesn’t match expectations Solution:
  • Check for exact text match - the comparison is case-sensitive
  • Look for extra whitespace, line breaks, or special characters
  • Make sure you’re checking text content, not attribute values (use selectors for attributes)
  • Verify the element contains the text vs. the text being in a child element

Timing Issues

Symptom: Step runs before text appears or updates Solution:
  • Add a Wait for Element step before your Check Text step
  • Ensure any API calls or state updates complete before verifying text
  • For text that updates after page load, consider adding a small wait

Variable Dropdown Is Empty

Symptom: When you toggle “Use variables”, no options appear Solution:
  • Variables only appear if declared in previous steps
  • Verify earlier steps (Extract Value, Run Python, API Request) ran successfully
  • Check that variable names are unique and properly saved