0

Background : I am trying to record video on iOS using MacOS with M1.

Problem : I am able to record video but after saving I can see video size is "Zero byte". I have not seen any error so far in a code or automation test and even on appium server :(

Anyone has observe this kind of behavior and already aware about fix?

2
  • Did you check permissions on the folder where you are trying to save the file?
    – Prome
    Commented Apr 28, 2023 at 12:51
  • yes, have req permissions for the directory Commented Apr 28, 2023 at 20:37

1 Answer 1

0

#Solution :

There are two appium native methods used for recording video on iOS platform irrespective of whether we are recording on simulator or real device?

  1. context.driver.start_recording_screen()
  2. context.driver.stop_recording_screen()

#Start - Video recording

context.driver.start_recording_screen(videoType='h264', videoQuality='high')

#Stop - Recording

video_file_name = f'{time.strftime("%Y%m%d_%H%M%S")}_{context.feature.name}_{context.scenario.name}.mp4'
video_file_path = os.path.join(video_recording_directory, video_file_name)

raw_video_data = context.driver.stop_recording_screen()

This raw data needs to be decoded from base64 inorder to create and save video file

with open(video_file_path, "wb") as fd:
                    fd.write(base64.b64decode(raw_video_data))
                log.info(f'{video_file_path} saved')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.