TestProject Forum

Contains Text? validation not working

See image below (I’ve also tried shortening the text to “Note: You have already created this Gift Message for the following”:

Proof it’s checking the right area:


Try using the Get Text action to verify first that the text is indeed the same as you expect.
Copy the result of this action into the expected text of the Contains Text action.

Sometimes it might include new lines, etc. making it not identical and failing the Contains Text action.

1 Like

To make it easier, how could I do just a partial contains text check rather than having to have an exact match?

This action already validates that the source text contains a portion and not exactly equal.
Can you please “spy” the element with the recorder inspector and check the contents of the text attribute from there to make sure that this text is accessible to the recorder?

Thank you so much for this @marat. So two things that I have learned are:

  1. @Chris.Rye may have found an issue with the Contains Text action. Although my problems are on Android, I experienced the same issue as Chris. TestProject found the element and was evaluating it but always failed on the comparison. However, if I cleared out the Text field under INPUTS within the step, it always passes.

  2. I used your suggestion, the Get Text action, and completely did away with the Contains Text action by using the optional Contains validation within Get Text. This does the exact thing as the Contains Text action. I confirmed TestProject is comparing correctly by typing banana into the Contains field in place of OK TITLE and it failed when executing. The other caveat is text format. You’ll notice my OK TITLE text contains a carriage return and is stacked on top of each other. That is because the entire message is formatted that way. The test will fail if I have OK TITLE in a single line. Hope this helps! Happy Testing!

Thanks, @phai for sharing these detailed findings.

We will improve the way how the special characters are represented so that it will be clear when they are there and why the strings are not equal.

1 Like