The text of element is different from expectation
※ English in this website is translated using machine translation. Please note that the content may not be 100% accurate.
If the text of the target element differs from the expected value in the text assertion step, the test result will display the following message
This "Text of the element is different from expectation" is one of the most common errors.
In this article, we will take an example of a common pattern and explain it. First, check the screenshot of the failed step to see which of the following cases applies.
- there is a difference at the step before the failed step compared to the screenshot at the time of recording or the previous successful step (the expected operation was not performed)
- the step before the failed step is OK, but the target element is not found in the failed step, or is found but failed.
1. unintended operation in the step before the failed step
Please check whether an unintended element was clicked or a validation error occurred in the form entry in the step prior to the failed step, and take action to ensure that the correct operation is performed.
For example, let's look at an example of an error in step 5 below.
First click on the "Check Screenshot" button to see what it looks like in step 5.
It is true that the character of the target being asserted is different from the previous success, and seems to be different from the expected value.
Next check to see if there was any unintended operation in the step prior to this step 5.
It seems that the user should have clicked on "English" in Step 4, but for some reason clicked on "Japanese," resulting in the screen being displayed in Japanese, and as a result, the user failed in Step 5.
In this case, it is necessary to check why the user performed a different operation (clicked on the wrong element) in Step 4 instead of Step 5. In this case, Autify AI may have found the wrong element, and a quick element update or re-recording may help.
See also the "Element not found" section "If the target element does not exist on the page" if necessary.
2. The target element has not been found in the failed step, or has been found but failed.
2-1. When the target element of the assertion looks fine on the appearance when looking at the screenshot of the test result, but it has failed
If you look at the error message, the result value is in a blank (no value) state.
Then click on the "View Screenshot" button to see what it looks like in step 2.
Looking at the screenshot of the test results, the element seems to be found without any problem and there seems to be no problem with the screen.
In this case, the target element may be a non-text element (e.g., an image element). Since text assertions are intended for text, they cannot be validated using this assertion command.
Visual regression testing for elements or Assertions on elements in a page.
2-2. When a line break is included in the target element in the difference comparison under the error message
Looking at the error message, text other than line breaks seems to be OK.
On the other hand, the expected value specifies "\n" for "line breaks", but the resulting value is "↵".
This may be due to a difference in the handling of line breaks.
In this case, specify the value to be included in the expected value with a line break expression (i.e., a line breaks is formed by pressing the Enter key).
Example: If a line break is expressed with a line break symbol
Example: if a line break is represented by the enter key.
The treatment of "line breaks" may differ depending on the browser used to execute the file.
Example: In Firefox browser, if a line break is included in the expected value, it fails, but in other browsers, it succeeds if there is a line break.
2-3. The target element is a calendar date value whose value is different from the expected value and the difference is 9 hours or 1 day
The error message indicates that the difference between the expected value and the resultant value is 9 hours or 1 day, and the test fails.
If you can identify the target element in the screenshot of the test results, it may be affected by the time zone.
Autify's It adopts Coordinated Universal Time (UTC) as a rule.
Therefore, please consider the following
- Specify the expected value considering that the test is executed in UTC, instead of the expected value assuming Japan time (JST).
2-4. When looking at the screenshot of the test results, the target element exists, but another element is asserted
For the following example, if you look at the screenshot screen of the failed step, you can see that the same element is asserted as it was during recording (the previous successful step).
However, what we really wanted to verify was the assertion of the date and time of the top line.
In this case, if you want to ensure that the intended element is the top, nth, bottom, etc., use the locator to specify the element to be targeted.
For specific instructions, see How do I interact with the elements in a table or list the way I intended?.
In addition to the above examples, if you think Autify may have found the wrong element, please refer to the "Target element not found" section "If the target element exists on the page but has not been found" as necessary.
2-5. When an email is opened differently than expected in the email test step
For the following example, the subject line seems to indicate that the user is opening a different email than when recording.
One possible cause of this is that another email was opened before the target email was received, and an assertion was made about the non-target email.
If it is possible that the next step is being taken before the reception is complete, please add a Sleep step before the target step.
Waiting for the email to be received before asserting may be successful.
For more information on the case where the mail function is not received and the specification of mail search, please also refer to the "In case mail is not received" and "About the specification of mail search for validation target" items in Mail Test as necessary.
If you are still having trouble...
Please contact us. We will work with you to resolve the issue.