Verifying with 'Text' vs. 'Value' Attributes

Overview

When creating verification steps in a test, it is crucial to select the correct attribute for validation. A common point of confusion is whether to use the text or value attribute. Using the wrong attribute can cause a verification step to fail, even if the expected content is visible on the page. This guide clarifies the difference between the two and explains when to use each one.

How It Works

Understanding the distinction between text and value is key to building successful verifications.

The 'text' Attribute

The text attribute should be used when verifying content that is visibly displayed on the user interface but is not inside an editable input field. This refers to the text that a user can see and read directly on the page. Use the text attribute for elements such as:

  • Labels
  • Headings
  • Paragraphs
  • Text within elements like <div> or <span>
  • Button text

For example, to verify the label “Loan Type HUD” on a page, you would use the text attribute because it is static, visible UI content.

The 'value' Attribute

The value attribute should be used when verifying data contained within form input fields. This content is stored in the element’s value attribute in the Document Object Model (DOM) and is what gets submitted in a form. Use the value attribute for:

  • Textboxes
  • Text areas

For example, if a user types their name into a “First Name” textbox, you would use the value attribute to verify the content of that textbox.

Troubleshooting Verification Failures

If a verification step fails, it may be due to an incorrect attribute selection. A common scenario is attempting to verify the value of a static text element, which does not have a value attribute, causing the step to fail.

To resolve this:

  1. Review the failing test step to identify the target element.
  2. Determine if the element is a static text element or an input field.
  3. Update the verification step to use the correct attribute: text for visible UI content or value for data inside an input field.
  4. Re-run the test to confirm that the verification now passes.