Taking screenshots

A picture speaks a thousand words, but in our case it can save a thousand seconds. It's a good practice to take an image at the point of test failure as it will help us save a lot of time, which is needed to go through the error logs. Also, sometimes images are needed as part of the test case itself. Here are two approaches:

  • Embedding a snapshot at the point of failure
  • Taking a screenshot and saving it for later use or reference

Embedding a snapshot in a cucumber report becomes fa+irly easy. Cucumber exposes you to the Scenario interface, which makes it slightly easier to query whether the scenario has failed or passed. For example, refer to the following snapshot of code; we are doing the following step by step:

  • The ...

Get Mobile Test Automation with Appium now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.