GeezerVison is showing github.com — add screen record commands · appium/ruby_lib_core@cdb02c2
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/appium_lib_core/android/device.rb +27Lines changed: 27 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -77,6 +77,27 @@ module Device | 77 | 77 | # @driver.get_performance_data package_name: package_name, data_type: data_type, data_read_timeout: 2 | 78 | 78 | # | 79 | 79 |
| | 80 | + # @!method start_recording_screen(package_name:, data_type:, data_read_timeout: 1000) | | 81 | + # Record the display of devices running Android 4.4 (API level 19) and higher. | | 82 | + # It records screen activity to an MPEG-4 file. Audio is not recorded with the video file. | | 83 | + # @param [String] file_path A path to save the video. `/sdcard/default.mp4` is by default. | | 84 | + # @param [String] video_size A video size. '1280x720' is by default. | | 85 | + # @param [String] time_limit Recording time. 180 second is by default. | | 86 | + # @param [String] bit_rate The video bit rate for the video, in megabits per second. 3000000(3Mbps) is by default. | | 87 | + # | | 88 | + # @example | | 89 | + # | | 90 | + # @driver.start_recording_screen file_path: '/sdcard/default.mp4', video_size: '1280x720', time_limit: '180', bit_rate: '3000000' | | 91 | + # | | 92 | + | | 93 | + # @!method stop_recording_screen | | 94 | + # Stop recording the screen. | | 95 | + # | | 96 | + # @example | | 97 | + # | | 98 | + # @driver.stop_recording_screen | | 99 | + # | | 100 | + | 80 | 101 | #### | 81 | 102 | ## class << self | 82 | 103 | #### | @@ -138,6 +159,12 @@ def get_performance_data(package_name:, data_type:, data_read_timeout: 1000) | 138 | 159 | dataReadTimeout: data_read_timeout | 139 | 160 | end | 140 | 161 | end | | 162 | + | | 163 | + Appium::Core::Device.add_endpoint_method(:start_recording_screen) do | | 164 | + def start_recording_screen(file_path: '/sdcard/default.mp4', video_size: '1280x720', time_limit: '180', bit_rate: '3000000') | | 165 | + execute :start_recording_screen, {}, filePath: file_path, videoSize: video_size, timeLimit: time_limit, bitRate: bit_rate | | 166 | + end | | 167 | + end | 141 | 168 | end | 142 | 169 | end | 143 | 170 | end # module Device | |
Collapse file Copy file name to clipboardExpand all lines: lib/appium_lib_core/common/command.rb +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -25,7 +25,7 @@ module Commands | 25 | 25 | is_keyboard_shown: [:get, 'session/:session_id/appium/device/is_keyboard_shown'.freeze], | 26 | 26 | get_network_connection: [:get, 'session/:session_id/network_connection'.freeze], | 27 | 27 | get_performance_data_types: [:post, 'session/:session_id/appium/performanceData/types'.freeze], | 28 | | - | | 28 | + stop_recording_screen: [:post, 'session/:session_id/appium/stop_recording_screen'.freeze] | 29 | 29 | # iOS | 30 | 30 | }.freeze | 31 | 31 |
| @@ -58,7 +58,8 @@ module Commands | 58 | 58 | start_activity: [:post, 'session/:session_id/appium/device/start_activity'.freeze], | 59 | 59 | end_coverage: [:post, 'session/:session_id/appium/app/end_test_coverage'.freeze], | 60 | 60 | set_network_connection: [:post, 'session/:session_id/network_connection'.freeze], | 61 | | - get_performance_data: [:post, 'session/:session_id/appium/getPerformanceData'.freeze] | | 61 | + get_performance_data: [:post, 'session/:session_id/appium/getPerformanceData'.freeze], | | 62 | + start_recording_screen: [:post, 'session/:session_id/appium/start_recording_screen'.freeze] | 62 | 63 | }.freeze | 63 | 64 |
| 64 | 65 | COMMAND_IOS = { | |
Collapse file Copy file name to clipboardExpand all lines: test/functional/android/android/device_test.rb +6-3Lines changed: 6 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -230,9 +230,12 @@ def test_open_notifications | 230 | 230 | @@driver.open_notifications | 231 | 231 | # shouldn't see the elements behind shade | 232 | 232 |
| 233 | | - assert_raises Selenium::WebDriver::Error::NoSuchElementError do | 234 | | - @@driver.find_element :accessibility_id, ':-|' | 235 | | - end | | 233 | + # Sometimes, we should wait animation | | 234 | + @@core.wait { | | 235 | + assert_raises Selenium::WebDriver::Error::NoSuchElementError do | | 236 | + @@driver.find_element :accessibility_id, ':-|' | | 237 | + end | | 238 | + } | 236 | 239 |
| 237 | 240 | # should see the notification | 238 | 241 | @@core.wait_true { text 'Mood ring' } | |
Collapse file Copy file name to clipboardExpand all lines: test/functional/android/webdriver/device_test.rb +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -76,7 +76,7 @@ def test_dismiss_alert | 76 | 76 | # assert @@driver.switch_to.alert.text.start_with?('Lorem ipsum dolor sit aie consectetur') | 77 | 77 | # assert @@driver.switch_to.alert.dismiss | 78 | 78 |
| 79 | | - assert_equal 'Cancel', @@driver.find_element(:id, 'android:id/button2').name | | 79 | + assert_equal 'CANCEL', @@driver.find_element(:id, 'android:id/button2').name | 80 | 80 | assert @@driver.find_element(:id, 'android:id/button2').click | 81 | 81 | end | 82 | 82 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/test_helper.rb +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,7 +32,7 @@ module Caps | 32 | 32 | platformName: :android, | 33 | 33 | automationName: 'uiautomator2', | 34 | 34 | app: 'test/functional/app/api.apk', | 35 | | - platformVersion: '7.1.1', | | 35 | + platformVersion: '6.0', | 36 | 36 | deviceName: 'Android Emulator', | 37 | 37 | appPackage: 'io.appium.android.apis', | 38 | 38 | appActivity: 'io.appium.android.apis.ApiDemos', | |
Collapse file Copy file name to clipboardExpand all lines: test/unit/android/device_test.rb +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -227,6 +227,15 @@ def test_get_performance_data_types | 227 | 227 | assert_requested(:post, "#{SESSION}/appium/performanceData/types", times: 1) | 228 | 228 | end | 229 | 229 |
| | 230 | + def test_stop_recording_screen | | 231 | + stub_request(:post, "#{SESSION}/appium/stop_recording_screen") | | 232 | + .to_return(headers: HEADER, status: 200, body: { value: ['a'] }.to_json) | | 233 | + | | 234 | + @driver.stop_recording_screen | | 235 | + | | 236 | + assert_requested(:post, "#{SESSION}/appium/stop_recording_screen", times: 1) | | 237 | + end | | 238 | + | 230 | 239 | ## with args | 231 | 240 |
| 232 | 241 | def test_available_contexts | @@ -444,6 +453,15 @@ def test_get_perfoemance_data | 444 | 453 |
| 445 | 454 | assert_requested(:post, "#{SESSION}/appium/getPerformanceData", times: 1) | 446 | 455 | end | | 456 | + | | 457 | + def test_start_recording_screen | | 458 | + stub_request(:post, "#{SESSION}/appium/start_recording_screen") | | 459 | + .to_return(headers: HEADER, status: 200, body: { value: ['a'] }.to_json) | | 460 | + | | 461 | + @driver.start_recording_screen | | 462 | + | | 463 | + assert_requested(:post, "#{SESSION}/appium/start_recording_screen", times: 1) | | 464 | + end | 447 | 465 | end | 448 | 466 | end | 449 | 467 | end |
|