Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Record Video Using Appium
// So I found out that its not easy to do this without the right code.
// Funny thing is that it puts a recording on the phone with some random name.mp4
// The hard thing was actually saving it locally.
// When you stop the recording its in a string 64 base you have to decode and then write that byte array to a file.
protected void screenRecordVideo() throws InterruptedException, IOException {
if (platform == OperatingSystem.ANDROID) {
((CanRecordScreen)driver).startRecordingScreen(
new AndroidStartScreenRecordingOptions()
.withVideoSize("1280x720")
.withTimeLimit(Duration.ofSeconds(5)
));
} else {
// not supported for iOS
}
Thread.sleep(5000);
String base64String = ((CanRecordScreen)driver).stopRecordingScreen();
byte[] decode = Base64.decodeBase64(base64String);
FileUtils.writeByteArrayToFile(new File("androidclip.mp4"), decode);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment