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.
Instructions for use:
- 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 Recording
in the Test Setup andStop Screen Recording
in 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 1.5.0.4 - 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:
Viewing videos
For Android recordings, file format is .mp4
that is easy to open with many tools. For iOS, file format is .ffmpeg
. To view ffmpeg videos, use ffplay
in the command line (in a computer where ffmpeg is installed):
ffplay appium-screenrecord-10.ffmpeg
Free word
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.
Top comments (4)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.