pythoniosautomated-testsappiumscreen-recording

Appium Python screen-recorded video is sped-up


I'm developing automatic tests in Appium Python in an iOS environment and I need to record the execution of the tests.

To start recording I use this method:

driver.start_recording_screen()

To stop recording and save the video, I use this one

def save_video(video, filename):
     log_folder = name_of_log_folder
     video_path = f'{log_folder}/{filename}.mp4'
     with open(video_path, 'wb') as output_file:
         output_file.write(base64.b64decode(video))

save_video(driver.stop_recording_screen(), 'video_name')

The video is created and records all the steps, but I noticed that it is much faster than running the actual test (it even seems to be twice as fast!).

To give you an idea of the timing:

I really see the very fast loading animations and spinners that spin like crazy

Is there a way to record the video and have it not be sped up, but instead mirror the real execution times?


Solution

  • This discrepancy can occur if the Frames Per Second (FPS) rate of the recorded video is different from the actual execution speed of your tests. Fortunately, in Appium Python, you can control the FPS rate of the recorded video using the videoFps parameter in the start_recording_screen() method.

    By default, the FPS rate is set to 10 FPS, which may result in a faster playback speed compared to the real-time execution of your tests. To address this issue, you can adjust the FPS rate to match the desired playback speed. Here's how you can do it:

    fps = "60"
    driver.start_recording_screen(videoFps=fps)
    

    In the above code, we've adjusted the videoFps parameter to 60 FPS, but you can modify it according to your test requirements. By setting the FPS rate to match the real-time execution speed of your tests, the recorded video should mirror the actual execution times more accurately.

    Try adjusting the FPS rate and re-run your tests to see if it resolves the issue of the recorded video being too fast compared to the real-time execution.

    I suggest anyone to check the documentation here (JSON Parameters section): https://appium.readthedocs.io/en/latest/en/commands/device/recording-screen/start-recording-screen/