At certain stages in your test you want to validate for the desired outcome. To do so use text, object or variable assertions.

Text and Variable Assertions

Once clicked a panel will open. You can choose the element or text you want to assert. Don't worry if the text isn't right. At this point you're just choosing the element or the type of object your test will assert (e.g TextView). You can also do a page level assertion just by choosing the whole screen.

Next you will choose:

  • Assert for a static text or a variable
  • Logic
  • If you choose to assert text you can alter the text you want to assert for
  • Choose between: Object assertion - We'll first look for the element and then assert his value. Page assertion - We'll look for the value anywhere on the page.

Choose "Add action".

Important:

Simple text assertions can fail if the text in your Object Tree includes special characters (e.g new line \n) but don't worry - 21 compliments it's assertions with computer vision as a back mechanism to ensure proper results.

In some scenarios the object tree might not expose the text or will the text in the object tree will be different than the one rendered. Use computer vision for such instances.

Other reasons assertions fail:

  • The text in the object tree doesn't match the text rendered (e.g one is small letters and one is capital letters).
  • The text includes special characters (see above).
  • Assertions are sensitive to small and capital letters so text should be precise.
  • Use logic - The text you assert for might be part of a sentence. Using "includes" or "Starts with" for more flexibility.
  • Finally, many times the text is different yet the difference is minor and difficult to notice.

Object Assertion

The steps to add an object assertion are similar:

  • Choose "Object assertion"
  • Choose the object you want to assert for from the viewport or the object tree
  • Choose the logic: you can assert for whether elements are/are not visible or whether checkboxes are checked or not

Congratulations! You just created your first test!

Did this answer your question?