Module: Appium::Android::Device
- Extended by:
- Forwardable
- Defined in:
- lib/appium_lib_core/android/device.rb,
lib/appium_lib_core/android/device/emulator.rb
Defined Under Namespace
Modules: Emulator
Class Method Summary collapse
Instance Method Summary collapse
-
#current_activity ⇒ String
Get current activity name.
-
#current_package ⇒ String
Get current package name.
-
#end_coverage(path, intent) ⇒ Object
Android only; Ends the test coverage and writes the results to the given path on device.
-
#get_clipboard(content_type: :plaintext) ⇒ Object
Set the content of device’s clipboard.
-
#get_display_density ⇒ Integer
Get connected device’s density.
-
#get_network_connection ⇒ Object
Get the device network connection current status See set_network_connection method for return value.
-
#get_performance_data(package_name: , data_type: , data_read_timeout: 1000) ⇒ Object
Get the resource usage information of the application.
-
#get_performance_data_types ⇒ Object
Get the information type of the system state which is supported to read such as cpu, memory, network, battery via adb commands.
-
#get_system_bars ⇒ String
Get system bar’s information.
-
#hide_keyboard(close_key = nil, strategy = nil) ⇒ Object
Hide the onscreen keyboard.
-
#is_keyboard_shown ⇒ Boolean
Get whether keyboard is displayed or not.
-
#open_notifications ⇒ Object
Open Android notifications.
-
#set_clipboard(content: , content_type: :plaintext, label: nil) ⇒ Object
Set the content of device’s clipboard.
-
#set_network_connection(mode) ⇒ Object
Set the device network connection mode.
-
#start_activity(opts) ⇒ Object
Android only.
- #start_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT', force_restart: nil, video_size: nil, time_limit: '180', bit_rate: '4000000') ⇒ Object
-
#toggle_airplane_mode ⇒ Object
Toggle flight mode on or off.
-
#toggle_data ⇒ Object
Switch the state of data service only for Android, and the device should be rooted.
-
#toggle_location_services ⇒ Object
Switch the state of the location service.
-
#toggle_wifi ⇒ Object
Switch the state of the wifi service only for Android.
Class Method Details
.extended(_mod) ⇒ Object
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/appium_lib_core/android/device.rb', line 249 def extended(_mod) Appium::Core::Device.extend_webdriver_with_forwardable Appium::Core::Device.add_endpoint_method(:open_notifications) do def open_notifications execute :open_notifications end end Appium::Core::Device.add_endpoint_method(:toggle_airplane_mode) do def toggle_airplane_mode execute :toggle_airplane_mode end alias_method :toggle_flight_mode, :toggle_airplane_mode end Appium::Core::Device.add_endpoint_method(:current_activity) do def current_activity execute :current_activity end end Appium::Core::Device.add_endpoint_method(:current_package) do def current_package execute :current_package end end Appium::Core::Device.add_endpoint_method(:get_system_bars) do def execute :get_system_bars end end Appium::Core::Device.add_endpoint_method(:get_display_density) do def get_display_density execute :get_display_density end end Appium::Core::Device.add_endpoint_method(:is_keyboard_shown) do def is_keyboard_shown # rubocop:disable Naming/PredicateName for compatibility execute :is_keyboard_shown end end Appium::Core::Device.add_endpoint_method(:get_network_connection) do def get_network_connection execute :get_network_connection end end Appium::Core::Device.add_endpoint_method(:get_performance_data_types) do def get_performance_data_types execute :get_performance_data_types end end Appium::Core::Device.add_endpoint_method(:toggle_wifi) do def toggle_wifi execute :toggle_wifi end end Appium::Core::Device.add_endpoint_method(:toggle_data) do def toggle_data execute :toggle_data end end Appium::Core::Device.add_endpoint_method(:toggle_location_services) do def toggle_location_services execute :toggle_location_services end end Appium::Core::Device.add_endpoint_method(:start_activity) do def start_activity(opts) raise 'opts must be a hash' unless opts.is_a? Hash app_package = opts[:app_package] raise 'app_package is required' unless app_package app_activity = opts[:app_activity] raise 'app_activity is required' unless app_activity app_wait_package = opts.fetch(:app_wait_package, '') app_wait_activity = opts.fetch(:app_wait_activity, '') unknown_opts = opts.keys - %i(app_package app_activity app_wait_package app_wait_activity) raise "Unknown options #{unknown_opts}" unless unknown_opts.empty? execute :start_activity, {}, appPackage: app_package, appActivity: app_activity, appWaitPackage: app_wait_package, appWaitActivity: app_wait_activity end end # Android, Override Appium::Core::Device.add_endpoint_method(:hide_keyboard) do def hide_keyboard(close_key = nil, strategy = nil) option = {} option[:key] = close_key if close_key option[:strategy] = strategy || :tapOutside # default to pressKey execute :hide_keyboard, {}, option end end # TODO: TEST ME Appium::Core::Device.add_endpoint_method(:end_coverage) do def end_coverage(path, intent) execute :end_coverage, {}, path: path, intent: intent end end Appium::Core::Device.add_endpoint_method(:set_network_connection) do def set_network_connection(mode) # TODO. Update set_network_connection as well # connection_type = {airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0} # raise ArgumentError, 'Invalid connection type' unless type_to_values.keys.include? mode # type = connection_type[mode] # execute :set_network_connection, {}, type: type execute :set_network_connection, {}, type: mode end end Appium::Core::Device.add_endpoint_method(:get_performance_data) do def get_performance_data(package_name:, data_type:, data_read_timeout: 1000) execute(:get_performance_data, {}, packageName: package_name, dataType: data_type, dataReadTimeout: data_read_timeout) end end add_screen_recording add_clipboard Emulator.emulator_commands end |
Instance Method Details
#current_activity ⇒ String
Get current activity name
|
|
# File 'lib/appium_lib_core/android/device.rb', line 19
|
#current_package ⇒ String
Get current package name
|
|
# File 'lib/appium_lib_core/android/device.rb', line 28
|
#end_coverage(path, intent) ⇒ Object
Android only; Ends the test coverage and writes the results to the given path on device.
|
|
# File 'lib/appium_lib_core/android/device.rb', line 126
|
#get_clipboard(content_type: :plaintext) ⇒ Object
Set the content of device’s clipboard.
|
|
# File 'lib/appium_lib_core/android/device.rb', line 221
|
#get_display_density ⇒ Integer
Get connected device’s density.
|
|
# File 'lib/appium_lib_core/android/device.rb', line 46
|
#get_network_connection ⇒ Object
Get the device network connection current status See set_network_connection method for return value
|
|
# File 'lib/appium_lib_core/android/device.rb', line 63
|
#get_performance_data(package_name: , data_type: , data_read_timeout: 1000) ⇒ Object
Get the resource usage information of the application. github.com/appium/appium-base-driver/blob/be29aec2318316d12b5c3295e924a5ba8f09b0fb/lib/mjsonwp/routes.js#L303
|
|
# File 'lib/appium_lib_core/android/device.rb', line 175
|
#get_performance_data_types ⇒ Object
Get the information type of the system state which is supported to read such as cpu, memory, network, battery via adb commands. github.com/appium/appium-base-driver/blob/be29aec2318316d12b5c3295e924a5ba8f09b0fb/lib/mjsonwp/routes.js#L300
|
|
# File 'lib/appium_lib_core/android/device.rb', line 165
|
#get_system_bars ⇒ String
Get system bar’s information
|
|
# File 'lib/appium_lib_core/android/device.rb', line 37
|
#hide_keyboard(close_key = nil, strategy = nil) ⇒ Object
Hide the onscreen keyboard
|
|
# File 'lib/appium_lib_core/android/device.rb', line 111
|
#is_keyboard_shown ⇒ Boolean
Get whether keyboard is displayed or not.
|
|
# File 'lib/appium_lib_core/android/device.rb', line 55
|
#open_notifications ⇒ Object
Open Android notifications
|
|
# File 'lib/appium_lib_core/android/device.rb', line 11
|
#set_clipboard(content: , content_type: :plaintext, label: nil) ⇒ Object
Set the content of device’s clipboard.
|
|
# File 'lib/appium_lib_core/android/device.rb', line 231
|
#set_network_connection(mode) ⇒ Object
Set the device network connection mode
|
|
# File 'lib/appium_lib_core/android/device.rb', line 147
|
#start_activity(opts) ⇒ Object
Android only. Start a new activity within the current app or launch a new app and start the target activity.
|
|
# File 'lib/appium_lib_core/android/device.rb', line 132
|
#start_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT', force_restart: nil, video_size: nil, time_limit: '180', bit_rate: '4000000') ⇒ Object
|
|
# File 'lib/appium_lib_core/android/device.rb', line 187
|
#toggle_airplane_mode ⇒ Object
Toggle flight mode on or off
|
|
# File 'lib/appium_lib_core/android/device.rb', line 103
|
#toggle_data ⇒ Object
Switch the state of data service only for Android, and the device should be rooted
|
|
# File 'lib/appium_lib_core/android/device.rb', line 83
|
#toggle_location_services ⇒ Object
Switch the state of the location service
|
|
# File 'lib/appium_lib_core/android/device.rb', line 93
|
#toggle_wifi ⇒ Object
Switch the state of the wifi service only for Android
|
|
# File 'lib/appium_lib_core/android/device.rb', line 73
|