Module: Appium::Core::Android::Device
- Extended by:
- Forwardable
- Defined in:
- lib/appium_lib_core/android/device.rb,
lib/appium_lib_core/android/device/screen.rb,
lib/appium_lib_core/android/device/network.rb,
lib/appium_lib_core/android/device/emulator.rb,
lib/appium_lib_core/android/device/clipboard.rb,
lib/appium_lib_core/android/device/performance.rb,
lib/appium_lib_core/android/device/auth_finger_print.rb
Defined Under Namespace
Modules: Authentication, Clipboard, Emulator, Network, Performance, Screen
Class Method Summary collapse
Instance Method Summary collapse
-
#current_activity ⇒ String
deprecated
Deprecated.
Use ‘mobile: getCurrentActivity’ extension instead.
-
#current_package ⇒ String
deprecated
Deprecated.
Use ‘mobile: getCurrentPackage’ extension instead.
-
#execute_cdp(cmd, **params) ⇒ Object
Execute Chrome Devtools protocol commands chromedevtools.github.io/devtools-protocol.
-
#finger_print(finger_id) ⇒ Object
Authenticate users by using their finger print scans on supported emulators.
-
#get_clipboard(content_type: :plaintext) ⇒ Object
Set the content of device’s clipboard.
-
#get_display_density ⇒ Integer
deprecated
Deprecated.
Use ‘mobile: getDisplayDensity’ extension instead.
-
#get_network_connection ⇒ Object
Get the device network connection current status See set_network_connection method for return value Same as #network_connection_type in selenium-webdriver.
-
#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
deprecated
Deprecated.
Use ‘mobile: getSystemBars’ extension instead.
-
#hide_keyboard(close_key = nil, strategy = nil) ⇒ Object
deprecated
Deprecated.
Use ‘mobile: hideKeyboard’ extension instead.
-
#location ⇒ ::Appium::Location
deprecated
Deprecated.
Use ‘mobile: getConnectivity’ extension instead.
-
#location= ⇒ Object
Set the location of the device.
-
#open_notifications ⇒ Object
Open Android notifications.
-
#set_clipboard(content: , content_type: :plaintext, label: nil) ⇒ Object
Set the content of device’s clipboard.
-
#set_location ⇒ Object
Set the location of the device.
-
#set_network_connection(mode) ⇒ Object
deprecated
Deprecated.
Use ‘mobile: setConnectivity’ extension instead.
-
#start_activity(opts) ⇒ Object
deprecated
Deprecated.
Use ‘mobile: startActivity’ extension instead.
-
#start_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT', file_field_name: nil, form_fields: nil, headers: nil, force_restart: nil, video_size: nil, time_limit: '180', bit_rate: '4000000', bug_report: nil) ⇒ String
Base64 encoded content of the recorded media file or an empty string if the file has been successfully uploaded to a remote location (depends on the actual options).
-
#toggle_airplane_mode ⇒ Object
deprecated
Deprecated.
Use ‘mobile: getConnectivity’ extension instead.
-
#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
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
# File 'lib/appium_lib_core/android/device.rb', line 365 def extended(_mod) ::Appium::Core::Device.extend_webdriver_with_forwardable ::Appium::Core::Device.add_endpoint_method(:open_notifications) do def open_notifications ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: openNotifications' extension instead" execute :open_notifications end end ::Appium::Core::Device.add_endpoint_method(:current_activity) do def current_activity ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getCurrentActivity' extension instead" execute :current_activity end end ::Appium::Core::Device.add_endpoint_method(:current_package) do def current_package ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getCurrentPackage' extension instead" execute :current_package end end ::Appium::Core::Device.add_endpoint_method(:get_system_bars) do def ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getSystemBars' extension instead" execute :get_system_bars end end # as alias to get_system_bars ::Appium::Core::Device.add_endpoint_method(:system_bars) do def ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getSystemBars' extension instead" execute :get_system_bars end end ::Appium::Core::Device.add_endpoint_method(:toggle_location_services) do def toggle_location_services ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: toggleGps' extension instead" execute :toggle_location_services end end ::Appium::Core::Device.add_endpoint_method(:start_activity) do def start_activity(opts) ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: startActivity' extension instead" raise 'opts must be a hash' unless opts.is_a? Hash option = {} 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 option[:appPackage] = app_package option[:appActivity] = app_activity app_wait_package = opts.fetch(:app_wait_package, nil) app_wait_activity = opts.fetch(:app_wait_activity, nil) option[:appWaitPackage] = app_wait_package if app_wait_package option[:appWaitActivity] = app_wait_activity if app_wait_activity intent_action = opts.fetch(:intent_action, nil) intent_category = opts.fetch(:intent_category, nil) intent_flags = opts.fetch(:intent_flags, nil) optional_intent_arguments = opts.fetch(:optional_intent_arguments, nil) dont_stop_app_on_reset = opts.fetch(:dont_stop_app_on_reset, nil) option[:intentAction] = intent_action if intent_action option[:intentCategory] = intent_category if intent_category option[:intentFlags] = intent_flags if intent_flags option[:optionalIntentArguments] = optional_intent_arguments if optional_intent_arguments option[:dontStopAppOnReset] = dont_stop_app_on_reset if dont_stop_app_on_reset execute :start_activity, {}, option end end # Android, Override included method in bridge ::Appium::Core::Device.add_endpoint_method(:hide_keyboard) do def hide_keyboard(close_key = nil, strategy = nil) ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: hideKeyboard' extension instead" option = {} option[:key] = close_key if close_key option[:strategy] = strategy if strategy execute :hide_keyboard, {}, option end end # Android, Override included method in bridge ::Appium::Core::Device.add_endpoint_method(:background_app) do def background_app(duration = 0) ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: backgroundApp' extension instead" execute :background_app, {}, seconds: duration end end ::Appium::Core::Device.add_endpoint_method(:execute_cdp) do # SeleniumWebdriver could already define this method return if method_defined? :execute_cdp def execute_cdp(cmd, **params) execute :chrome_send_command, {}, { cmd: cmd, params: params } end end Screen.add_methods Performance.add_methods Network.add_methods Clipboard.add_methods Emulator.add_methods Authentication.add_methods end |
Instance Method Details
#current_activity ⇒ String
Use ‘mobile: getCurrentActivity’ extension instead.
Get current activity name
|
# File 'lib/appium_lib_core/android/device.rb', line 39
|
#current_package ⇒ String
Use ‘mobile: getCurrentPackage’ extension instead.
Get current package name
|
# File 'lib/appium_lib_core/android/device.rb', line 49
|
#execute_cdp(cmd, **params) ⇒ Object
Execute Chrome Devtools protocol commands chromedevtools.github.io/devtools-protocol
|
# File 'lib/appium_lib_core/android/device.rb', line 341
|
#finger_print(finger_id) ⇒ Object
Authenticate users by using their finger print scans on supported emulators.
|
# File 'lib/appium_lib_core/android/device.rb', line 330
|
#get_clipboard(content_type: :plaintext) ⇒ Object
Set the content of device’s clipboard.
|
# File 'lib/appium_lib_core/android/device.rb', line 309
|
#get_display_density ⇒ Integer
Use ‘mobile: getDisplayDensity’ extension instead.
Get connected device’s density.
|
# File 'lib/appium_lib_core/android/device.rb', line 70
|
#get_network_connection ⇒ Object
Get the device network connection current status See set_network_connection method for return value Same as #network_connection_type in selenium-webdriver.
Returns a key of {:airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0}
in #network_connection_type Returns a number of the mode in #get_network_connection
|
# File 'lib/appium_lib_core/android/device.rb', line 80
|
#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 250
|
#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 239
|
#get_system_bars ⇒ String
Use ‘mobile: getSystemBars’ extension instead.
Get system bar’s information
|
# File 'lib/appium_lib_core/android/device.rb', line 59
|
#hide_keyboard(close_key = nil, strategy = nil) ⇒ Object
Use ‘mobile: hideKeyboard’ extension instead.
Hide the onscreen keyboard
|
# File 'lib/appium_lib_core/android/device.rb', line 175
|
#location ⇒ ::Appium::Location
Use ‘mobile: getConnectivity’ extension instead.
Get the location of the device.
|
# File 'lib/appium_lib_core/android/device.rb', line 117
|
#location= ⇒ Object
Set the location of the device.
|
# File 'lib/appium_lib_core/android/device.rb', line 128
|
#open_notifications ⇒ Object
Open Android notifications
|
# File 'lib/appium_lib_core/android/device.rb', line 30
|
#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 319
|
#set_location ⇒ Object
Set the location of the device.
|
# File 'lib/appium_lib_core/android/device.rb', line 138
|
#set_network_connection(mode) ⇒ Object
Use ‘mobile: setConnectivity’ extension instead.
Set the device network connection mode Same as #network_connection_type
in selenium-webdriver.
Or the key matched with {:airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0}
Value (Alias) | Data | Wifi | Airplane Mode
-------------------------------------------------
1 (Airplane Mode) | 0 | 0 | 1
6 (All network on) | 1 | 1 | 0
4 (Data only) | 1 | 0 | 0
2 (Wifi only) | 0 | 1 | 0
0 (None) | 0 | 0 | 0
|
# File 'lib/appium_lib_core/android/device.rb', line 216
|
#start_activity(opts) ⇒ Object
Use ‘mobile: startActivity’ extension instead.
Android only. Start a new activity within the current app or launch a new app and start the target activity.
Read developer.android.com/studio/command-line/adb#IntentSpec for each flags.
|
# File 'lib/appium_lib_core/android/device.rb', line 191
|
#start_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT', file_field_name: nil, form_fields: nil, headers: nil, force_restart: nil, video_size: nil, time_limit: '180', bit_rate: '4000000', bug_report: nil) ⇒ String
Returns Base64 encoded content of the recorded media file or an empty string if the file has been successfully uploaded to a remote location (depends on the actual options).
|
# File 'lib/appium_lib_core/android/device.rb', line 263
|
#toggle_airplane_mode ⇒ Object
Use ‘mobile: getConnectivity’ extension instead.
Toggle flight mode on or off
|
# File 'lib/appium_lib_core/android/device.rb', line 166
|
#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 106
|
#toggle_location_services ⇒ Object
Switch the state of the location service
|
# File 'lib/appium_lib_core/android/device.rb', line 155
|
#toggle_wifi ⇒ Object
Switch the state of the wifi service only for Android
|
# File 'lib/appium_lib_core/android/device.rb', line 95
|