Last active
March 18, 2020 17:55
-
-
Save grndvl1/62804d401766207d293e1bb3b0885150 to your computer and use it in GitHub Desktop.
Record Video Using Appium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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