Below given are some of the most common issues while using the Text verification NLP Grammar.
Verifying incorrect element attribute instead of text
Text is not present on the page
Incorrect Element Type selected in the NLP Statement
Verification Text different from actual Text in HTML
Whitespaces(space, tab e.t.c) in the HTML
Incorrect Case in HTML
1. Verifying incorrect element attribute instead of text
In such cases, the user might be trying to verify the text in an element but using an incorrect NLP. Here's an example:
For clicking on the above button, users might use the NLPs like:
Click on button with title test data
Click on the element with title test data
thinking that title in the NLP refers to the text in the element. However, the above NLPs check for the element attribute named 'title' instead of the text in the button. Since there is no 'title' attribute for this element, the Test Step would fail.
Solution:
Use the NLP that mention text for text verifications such as:
Click on the element with text test data
Click on the button with text test data
2. Verified Text is not present on the page
The very first step would be to check if the text is actually present on the page or not. Please check the screenshot next to the failed Step to see whether the current page contains the specified Text. This solution is pretty straightforward.
3. Incorrect Element Type selected in the NLP Statement
In the below example, we are using the NLP Statement 'Click on button with text Go to Travel'. To the user, the element with the text 'Go to Travel' seems like a button but the developer created it as a link(an anchor element).
Since this element is actually a link, the test looks only for button elements in the page and therefore fails to find it.
Solution:
Specify the element type only after checking it in the HTML source or use the generic templates such as 'Click on element with text Go to Travel'.
4. The provided verification Text and actual Text in HTML are different
The text in the HTML Source is given in lowercase but its shown in the page in a different format(case).
As you can see, the actual text in the Div element is all in lowercase. Developer used CSS Transformation to represent the text in different ways in the UI.
Solution:
While automating your application, if you are facing an error with Text Verification, please use the actual text contained inside the HTML Code instead of copying from the page.
5. The text in the HTML contains White spaces
In some cases, the actual text inside the HTML Code contains white spaces and these are ignored when text is copied from the page.
As you can see, the HTML text contains white-spaces and if we don't use the exact text in Test Step, it might fail during comparison.
Solution:
Use the Text Verification NLP Grammar using 'contains text' such as:
- Verify that the current page title contains test data
- Verify that the current page URL contains test data
- Verify that the element ui identifier displays text contains test data
and so on...
If the Grammar you are using doesn't have a 'contains' counterpart, please use the contains function in the XPath for the element - XPath String Functions
6. Comparison with incorrect Case
Text Comparison templates on Testsigma are case sensitive. Please check and confirm that the verification Text test data is exactly the same case as the Text on the Web page. For example, if the page displays text as "DashBoard" and user is giving the test data as "Dashboard" in the Test step, the step will fail due to the text mismatch.
Solution:
Copy the verification text from the HTML Source so as to get the correct Text.