DEV Community

loading...

Appium & Robot Framework: Record Test Execution

laojala profile image Laura Ojala (she/they) Updated on ・2 min read

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:

  1. If test is run in iPhone, install ffmpeg in the Mac where Appium is running: brew install ffmpeg
  2. Simple use case: Use Appium Library's keyword Start Screen Recording in the Test Setup and Stop 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.
  3. 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:
  4. 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
Enter fullscreen mode Exit fullscreen mode

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.

Discussion (4)

pic
Editor guide
Collapse
ivychloris profile image
ivy-chloris

Hi Laura,

Your post is simple and easy. I'm working with appium library and robot framework to automate a windows application. I'm facing problems with file browsing window. I'm trying to upload a file from local directory to the windows application which is also on the same machine. I used Input text and the file name, this does nothing . Do you have an idea how I can upload a file to the windows application?

Collapse
laojala profile image
Laura Ojala (she/they) Author

Hi! I have no idea if Appium can access those dialogs (in other words, it might be possible). If you can not do file upload using Appium, this library should be able to do it: github.com/nokia/robotframework-au...

Collapse
ivychloris profile image
ivy-chloris

Thanks Laura, I've tried AutoIT, it works like a charm. May I ask your advice related to appium/robot framework in case I have questions in the future?

Thread Thread
laojala profile image
Laura Ojala (she/they) Author • Edited

Feel free to! Also (Robot Framework Slack)[robotframework-slack-invite.heroku...] is a very good place for questions :-)