Checking data with assertions

Once you have a test case accepted from a crawl or manually recorded, you can add assertions to it in order to validate that the data on the screen is correct. For example, if you want to verify that the text of some element on screen contains a specific value, you can add an assertion to perform that validation at the time the test reaches that screen. You can also control the flow of the test by adding actions to take, depending on the result of an assertion.

There are two main types of assertions: element and page. Element assertions check the content of text within a specific element (typically TextView on Android, and UITextView on iOS) or an image (typically an ImageView on Android, and an UIImageView on iOS). Page assertions primarily check whether or not a specific element is present on the screen.

Both types of assertions can work with dynamic variables whose values are based on text found in elements on a screen. Variables are retained as the test progresses from screen to screen, and can be used to verify if something seen on a prior screen is present on the current screen.

After assertions are added to a screen, they will be checked when the test encounters that screen. If an assertion fails, the entire test will fail as a “defect”, and you will be able to see exactly what happened in the test results.