Test Case Failures Due to Link Text Capture Issues


In automated testing, test failures often occur when the recorder captures link text differently between the UI and HTML, such as in uppercase in the UI and lowercase in HTML. This guide helps you identify the issue and adjust settings to ensure you capture the correct elements in your tests, avoiding these failures.


Prerequisites

Before you proceed, ensure you know how to create or update an Element and a Test Case.


  • Check if the recorder captures link text from the HTML instead of the visible text in the UI.
  • Compare the captured text with what you see in the UI to spot differences. view link text capture issue
ℹ️Example:

    If the UI displays LOGIN but the HTML shows login, the recorder may capture the lowercase version, which could lead to a test case failure.


Changing Element Details

  • Change the locator setting in your test automation tool from Link text to XPath.
  • This adjustment allows the recorder to identify the element based on its structure rather than just the text.
  • If needed, manually update the captured link text to match the UI-visible text, ensuring the test case reflects what users see on the screen. updating element from link text
NOTE:

Using XPath or other reliable locators reduces the risk of capturing incorrect text, especially when differences exist between UI and HTML text.


Dealing with UI and HTML Text Mismatches

  • Compare the UI text with the HTML source to identify any inconsistencies that might cause the recorder to capture the wrong text.
  • Modify your test case to use the visible UI text for element identification.
  • Ensure the locator strategy aligns with the format users see in the UI.
  • Consider using unique attributes like data-test-id or other identifiers instead of relying solely on link text. This approach minimises the risk of mismatches between the UI and HTML representations.
ℹ️Example:

    If the UI shows SUBMIT, but the HTML has it as submit, adjust your test case using the visible UI text to account for this difference.

NOTE:
  • You should implement more automated solutions (like XPath or unique attributes) to enhance test stability and reduce the need for ongoing manual intervention.
  • In contrast, manual updates to captured text can resolve specific issues.