The latest release of the Robot Framework's Appium Library introduces keywords for recording a video of the Appium test execution in iOS and Android phones.
- If test is run in iPhone, install ffmpeg in the Mac where Appium is running:
brew install ffmpeg
Simple use case: Use Appium Library's keyword
Start Screen Recordingin the Test Setup and
Stop Screen Recordingin the Test Teardown. Recording is stored in the same place where Robot test case reports are. Video file is not stored permanently to the storage of the phone.
Error-proof use case: Some Android phones (for example Huawei models) are not capable of recording the screen and the test case will fail (in the latest Appium library 184.108.40.206 - this might change in the future). It is a good idea to start and stop recording using a keyword
Run Keyword And Ignore Error(remember also import BuiltIn library for the Robot Framework code). Here's an example of this error-proof case:
Storing recording only for failed tests: Here's an example code that stores screen recording only when a test case fails:
In my opinion, this example showcases nicely how the use of readily available Robot Framework libraries reduces the amount of test automation code (and thus less maintenance and bugs in it!). Capturing video of the screen is now only a few simple lines of code, whereas file handling using native Appium would require more logic.