From 8fa295dfd0de8a6bc47f1414698fbd72fb6ccaa5 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Tue, 12 May 2020 11:11:43 +0900 Subject: [PATCH] docs: Added Ruby and Python for audio capture, add mobile command (#14321) * docs: Added Ruby and Python for audio capture, add mobile command * fix ruby * fix sleep in python --- commands-yml/commands/mobile-command.yml | 2 ++ .../writing-running-appium/ios/audio-capture.md | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/commands-yml/commands/mobile-command.yml b/commands-yml/commands/mobile-command.yml index 913c8beef..4e86937de 100644 --- a/commands-yml/commands/mobile-command.yml +++ b/commands-yml/commands/mobile-command.yml @@ -63,6 +63,8 @@ | mobile:getAppearance | Get the device's UI appearance style via `xcrun simctl ui`. It returns `light`, `dark`, `unknown` or `unsupported` (below iOS 12). ||| | mobile:setAppearance | Set the device's UI appearance style via `xcrun simctl ui` or Siri command. | `{style}` | `{style: 'dark'}` | | mobile:getDeviceTime | Get time of the device under test. https://momentjs.com/docs/ is the full list of supported datetime format specifiers. Defaults to `YYYY-MM-DDTHH:mm:ssZ` which is ISO-8601. | `{format}` | `{format: 'YYYY-MM'}` | + | mobile:startAudioRecording | Start recording audio stream. Read [Audio Capture From iOS Simulators and Real Devices](/docs/en/writing-running-appium/ios/audio-capture.md) for more details | | | + | mobile:stopAudioRecording | Stop and store the recording audio stream. Read [Audio Capture From iOS Simulators and Real Devices](/docs/en/writing-running-appium/ios/audio-capture.md) for more details | | | ### Android | Command | Description | Argument | Argument Example | diff --git a/docs/en/writing-running-appium/ios/audio-capture.md b/docs/en/writing-running-appium/ios/audio-capture.md index 501c67594..2b67e7fd7 100644 --- a/docs/en/writing-running-appium/ios/audio-capture.md +++ b/docs/en/writing-running-appium/ios/audio-capture.md @@ -42,6 +42,22 @@ try (FileOutputStream fos = new FileOutputStream("out.mp4")) { } ``` +```ruby +# Ruby +@driver.execute_script 'mobile: startAudioRecording', audioInput: ':0' +sleep 10 +base64_str = @driver.execute_script 'mobile: stopAudioRecording' +File.write 'out.mp4', Base64.decode64(base64_str) +``` + +```python +# Python +driver.execute_script('mobile: startAudioRecording', {'audioInput': ':1'}) +time.sleep(10) +base64_str = driver.execute_script('mobile: stopAudioRecording') +with open('out.mp4', 'wb') as f: + f.write(base64.b64decode(base64_str)) +``` ### Server Requirements