Recording iOS Appium Tests
*** Code is available on Github ***
You will need Homebrew installed to record an iOS appium test.
Tools: Homebrew
Install Homebrew from the command line.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install FFmpeg using Homebrew by running the command:
brew install ffmpeg
FFmpeg, a robust open-source software project, offers a suite of libraries and programs for comprehensive multimedia data management. Renowned for its capabilities, FFmpeg is extensively utilized in audio and video processing tasks.
Let's use the appium startup code from the previous Story => Crafting a Simple Ruby Appium iOS Test.
require 'appium_lib'
# Set your desired capabilities
caps = {
"platformName": "iOS",
"appium:platformVersion": "17.2",
"appium:deviceName": "iPhone 15 Pro Max",
"appium:automationName": "XCUITest",
"appium:app": "com.apple.Preferences"
}
# Instantiate and start a new Appium Driver
driver = Appium::Driver.new(caps:, appium_lib: { server_url: 'http://127.0.0.1:4723/' }).start_driver
# Record Test
Start Recording Screen:
driver.start_recording_screen
: Begins recording the screen with the specified video quality ('high' in this case).
# Record Test
driver.start_recording_screen video_quality: 'high'
Perform Actions on the App:
- The script interacts with the app by finding elements with specific names and clicking on them. In this case, it clicks “General” and “About.”
# Perform actions on the app
driver.find_element(name: "General").click
sleep 1
driver.find_element(name: "About").click
Stop Recording Screen:
driver.driver.stop_recording_screen
: Stops the screen recording.
# Stop recording screen
recording = driver.stop_recording_screen
Save Recording to a File:
- The recorded screen data is received as a Base64-encoded string (
recording
). This data is then decoded and saved to a file named 'video.mp4.'
# Save recording to a file
File.open('video.mp4', 'wb') do |file|
file.write(Base64.decode64(recording))
end
Easy Peasy 👌

Let’s remove that hard sleep 1 with some fancy wait logic => Click Here