Module: Appium::Core::Device
- Extended by:
- Forwardable
- Defined in:
- lib/appium_lib_core/device.rb,
lib/appium_lib_core/device/value.rb,
lib/appium_lib_core/device/context.rb,
lib/appium_lib_core/device/setting.rb,
lib/appium_lib_core/device/keyboard.rb,
lib/appium_lib_core/device/keyevent.rb,
lib/appium_lib_core/device/app_state.rb,
lib/appium_lib_core/device/device_lock.rb,
lib/appium_lib_core/device/ime_actions.rb,
lib/appium_lib_core/device/screen_record.rb,
lib/appium_lib_core/device/touch_actions.rb,
lib/appium_lib_core/device/app_management.rb,
lib/appium_lib_core/device/battery_status.rb,
lib/appium_lib_core/device/file_management.rb,
lib/appium_lib_core/device/image_comparison.rb,
lib/appium_lib_core/device/clipboard_content_type.rb
Defined Under Namespace
Modules: AppManagement, AppState, BatteryStatus, Clipboard, Context, DeviceLock, FileManagement, ImageComparison, ImeActions, KeyEvent, Keyboard, Setting, TouchActions, Value Classes: ScreenRecord
Class Method Summary collapse
- .add_endpoint_method(method) ⇒ Object
- .create_bridge_command(method) ⇒ Object
- .delegate_driver_method(method) ⇒ Object
-
.delegate_from_appium_driver(method, delegation_target = :driver) ⇒ Object
For ruby_lib compatibility.
- .extend_webdriver_with_forwardable ⇒ Object
- .extended(_mod) ⇒ Object
Instance Method Summary collapse
-
#activate_app(app_id) ⇒ Hash
Activate(Launch) the specified app.
-
#app_installed?(app_id) ⇒ Boolean
Check whether the specified app is installed on the device.
-
#app_strings(language = nil) ⇒ Hash
Return the hash of all localization strings.
-
#available_contexts ⇒ Array<String>
All usable contexts, as an array of strings.
-
#background_app(duration = 0) ⇒ String
Backgrounds the app for a set number of seconds.
-
#close_app ⇒ Object
Close an app on device.
-
#current_context ⇒ String
The context currently being used.
-
#device_locked? ⇒ Object
Check current device status is weather locked or not.
-
#device_time ⇒ Object
Get the time on the device.
-
#get_settings ⇒ Object
Get appium Settings for current test session.
-
#hide_keyboard(close_key = nil, strategy = nil) ⇒ Object
Hide the onscreen keyboard.
-
#ime_activate(ime_name) ⇒ Object
Android only.
-
#ime_activated ⇒ Object
Android only.
-
#ime_active_engine ⇒ Object
Android only.
-
#ime_available_engines ⇒ Object
Android only.
-
#ime_deactivate ⇒ Object
Android only.
-
#install_app(path, replace: nil, timeout: nil, allow_test_packages: nil, use_sdcard: nil, grant_permissions: nil) ⇒ Object
Install the given app onto the device.
-
#is_keyboard_shown ⇒ Boolean
Get whether keyboard is displayed or not.
-
#keyevent(key, metastate = nil) ⇒ Object
Send keyevent on the device.(Only for Selendroid) developer.android.com/reference/android/view/KeyEvent.html.
-
#launch_app ⇒ Object
Start the simulator and application configured with desired capabilities.
-
#lock(duration = nil) ⇒ String
Lock the device.
-
#long_press_keycode(key, metastate: [], flags: []) ⇒ Object
Long press keycode on the device.
-
#press_keycode(key, metastate: [], flags: []) ⇒ Object
Press keycode on the device.
-
#pull_file(path) ⇒ Object
Retrieve a file from the device.
-
#pull_folder(path) ⇒ Object
Retrieve a folder from the device.
-
#push_file(path, filedata) ⇒ Object
Place a file in a specific location on the device.
- #remove_app(app_id, keep_data: nil, timeout: nil) ⇒ Object
-
#replace_value(element, *value) ⇒ Object
Replace the value to element directly.
-
#reset ⇒ Object
Reset the device, relaunching the application.
-
#save_viewport_screenshot ⇒ Object
Save screenshot except for status bar while ‘@driver.save_screenshot` save entire screen.
-
#set_context(context) ⇒ Object
Change the context to the given context.
-
#set_immediate_value(element, *value) ⇒ Object
Set the value to element directly.
-
#shake ⇒ Object
Cause the device to shake.
- #stop_and_save_recording_screen(file_path) ⇒ Object
- #stop_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT') ⇒ Object
-
#take_element_screenshot(element, png_path) ⇒ File
Path to the screenshot.
-
#terminate_app(app_id) ⇒ Boolean
Terminate the specified app.
-
#unlock ⇒ Object
Unlock the device.
-
#update_settings(settings) ⇒ Object
Update Appium Settings for current test session.
Class Method Details
.add_endpoint_method(method) ⇒ Object
533 534 535 536 537 538 |
# File 'lib/appium_lib_core/device.rb', line 533 def add_endpoint_method(method) block_given? ? create_bridge_command(method, &Proc.new) : create_bridge_command(method) delegate_driver_method method delegate_from_appium_driver method end |
.create_bridge_command(method) ⇒ Object
561 562 563 564 565 566 567 568 |
# File 'lib/appium_lib_core/device.rb', line 561 def create_bridge_command(method) ::Appium::Core::Base::Bridge::MJSONWP.class_eval do block_given? ? class_eval(&Proc.new) : define_method(method) { execute method } end ::Appium::Core::Base::Bridge::W3C.class_eval do block_given? ? class_eval(&Proc.new) : define_method(method) { execute method } end end |
.delegate_driver_method(method) ⇒ Object
555 556 557 558 |
# File 'lib/appium_lib_core/device.rb', line 555 def delegate_driver_method(method) return if ::Appium::Core::Base::Driver.method_defined? method ::Appium::Core::Base::Driver.class_eval { def_delegator :@bridge, method } end |
.delegate_from_appium_driver(method, delegation_target = :driver) ⇒ Object
For ruby_lib compatibility
550 551 552 |
# File 'lib/appium_lib_core/device.rb', line 550 def delegate_from_appium_driver(method, delegation_target = :driver) def_delegator delegation_target, method end |
.extend_webdriver_with_forwardable ⇒ Object
541 542 543 544 545 546 |
# File 'lib/appium_lib_core/device.rb', line 541 def extend_webdriver_with_forwardable return if ::Appium::Core::Base::Driver.is_a? Forwardable ::Appium::Core::Base::Driver.class_eval do extend Forwardable end end |
.extended(_mod) ⇒ Object
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
# File 'lib/appium_lib_core/device.rb', line 475 def extended(_mod) extend_webdriver_with_forwardable add_endpoint_method(:shake) do def shake execute :shake end end add_endpoint_method(:device_time) do def device_time execute :device_time end end add_endpoint_method(:take_element_screenshot) do def take_element_screenshot(element, png_path) result = execute :take_element_screenshot, id: element.ref extension = File.extname(png_path).downcase if extension != '.png' ::Appium::Logger.warn 'name used for saved screenshot does not match file type. '\ 'It should end with .png extension' end File.open(png_path, 'wb') { |f| f << result.unpack('m')[0] } end end add_endpoint_method(:save_viewport_screenshot) do def (png_path) extension = File.extname(png_path).downcase if extension != '.png' ::Appium::Logger.warn 'name used for saved screenshot does not match file type. '\ 'It should end with .png extension' end = execute_script('mobile: viewportScreenshot') File.open(png_path, 'wb') { |f| f << .unpack('m')[0] } end end Value.add_methods Setting.add_methods KeyEvent.add_methods Context.add_methods ImeActions.add_methods DeviceLock.add_methods TouchActions.add_methods FileManagement.add_methods Keyboard.add_methods AppManagement.add_methods ScreenRecord.add_methods ImageComparison.add_methods AppState.add_methods end |
Instance Method Details
#activate_app(app_id) ⇒ Hash
Activate(Launch) the specified app.
|
|
# File 'lib/appium_lib_core/device.rb', line 144
|
#app_installed?(app_id) ⇒ Boolean
Check whether the specified app is installed on the device
|
|
# File 'lib/appium_lib_core/device.rb', line 122
|
#app_strings(language = nil) ⇒ Hash
Return the hash of all localization strings.
|
|
# File 'lib/appium_lib_core/device.rb', line 171
|
#available_contexts ⇒ Array<String>
Returns All usable contexts, as an array of strings.
|
|
# File 'lib/appium_lib_core/device.rb', line 408
|
#background_app(duration = 0) ⇒ String
Backgrounds the app for a set number of seconds. This is a blocking application
|
|
# File 'lib/appium_lib_core/device.rb', line 191
|
#close_app ⇒ Object
Close an app on device
|
|
# File 'lib/appium_lib_core/device.rb', line 40
|
#current_context ⇒ String
Returns The context currently being used.
|
|
# File 'lib/appium_lib_core/device.rb', line 400
|
#device_locked? ⇒ Object
Check current device status is weather locked or not
|
|
# File 'lib/appium_lib_core/device.rb', line 72
|
#device_time ⇒ Object
Get the time on the device
|
|
# File 'lib/appium_lib_core/device.rb', line 80
|
#get_settings ⇒ Object
Get appium Settings for current test session
|
|
# File 'lib/appium_lib_core/device.rb', line 308
|
#hide_keyboard(close_key = nil, strategy = nil) ⇒ Object
Hide the onscreen keyboard
|
|
# File 'lib/appium_lib_core/device.rb', line 204
|
#ime_activate(ime_name) ⇒ Object
Android only. Make an engine that is available active.
|
|
# File 'lib/appium_lib_core/device.rb', line 350
|
#ime_activated ⇒ Object
Android only. Indicates whether IME input is active at the moment (not if it is available).
|
|
# File 'lib/appium_lib_core/device.rb', line 375
|
#ime_active_engine ⇒ Object
Android only. Get the name of the active IME engine.
|
|
# File 'lib/appium_lib_core/device.rb', line 367
|
#ime_available_engines ⇒ Object
Android only. List all available input engines on the machine.
|
|
# File 'lib/appium_lib_core/device.rb', line 359
|
#ime_deactivate ⇒ Object
Android only. De-activates the currently-active IME engine.
|
|
# File 'lib/appium_lib_core/device.rb', line 383
|
#install_app(path, replace: nil, timeout: nil, allow_test_packages: nil, use_sdcard: nil, grant_permissions: nil) ⇒ Object
Install the given app onto the device
|
|
# File 'lib/appium_lib_core/device.rb', line 94
|
#is_keyboard_shown ⇒ Boolean
Get whether keyboard is displayed or not.
|
|
# File 'lib/appium_lib_core/device.rb', line 219
|
#keyevent(key, metastate = nil) ⇒ Object
Send keyevent on the device.(Only for Selendroid) developer.android.com/reference/android/view/KeyEvent.html
|
|
# File 'lib/appium_lib_core/device.rb', line 227
|
#launch_app ⇒ Object
Start the simulator and application configured with desired capabilities
|
|
# File 'lib/appium_lib_core/device.rb', line 32
|
#lock(duration = nil) ⇒ String
Lock the device
|
|
# File 'lib/appium_lib_core/device.rb', line 180
|
#long_press_keycode(key, metastate: [], flags: []) ⇒ Object
Long press keycode on the device. developer.android.com/reference/android/view/KeyEvent.html
|
|
# File 'lib/appium_lib_core/device.rb', line 258
|
#press_keycode(key, metastate: [], flags: []) ⇒ Object
Press keycode on the device. developer.android.com/reference/android/view/KeyEvent.html
|
|
# File 'lib/appium_lib_core/device.rb', line 238
|
#pull_file(path) ⇒ Object
Retrieve a file from the device. This can retrieve an absolute path or a path relative to the installed app (iOS only).
|
|
# File 'lib/appium_lib_core/device.rb', line 288
|
#pull_folder(path) ⇒ Object
Retrieve a folder from the device.
|
|
# File 'lib/appium_lib_core/device.rb', line 299
|
#push_file(path, filedata) ⇒ Object
Place a file in a specific location on the device.
|
|
# File 'lib/appium_lib_core/device.rb', line 278
|
#remove_app(app_id, keep_data: nil, timeout: nil) ⇒ Object
|
|
# File 'lib/appium_lib_core/device.rb', line 110
|
#replace_value(element, *value) ⇒ Object
Replace the value to element directly
|
|
# File 'lib/appium_lib_core/device.rb', line 342
|
#reset ⇒ Object
Reset the device, relaunching the application.
|
|
# File 'lib/appium_lib_core/device.rb', line 48
|
#save_viewport_screenshot ⇒ Object
Save screenshot except for status bar while ‘@driver.save_screenshot` save entire screen.
|
|
# File 'lib/appium_lib_core/device.rb', line 316
|
#set_context(context) ⇒ Object
Change the context to the given context.
|
|
# File 'lib/appium_lib_core/device.rb', line 391
|
#set_immediate_value(element, *value) ⇒ Object
Set the value to element directly
|
|
# File 'lib/appium_lib_core/device.rb', line 334
|
#shake ⇒ Object
Cause the device to shake
|
|
# File 'lib/appium_lib_core/device.rb', line 56
|
#stop_and_save_recording_screen(file_path) ⇒ Object
|
|
# File 'lib/appium_lib_core/device.rb', line 460
|
#stop_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT') ⇒ Object
|
|
# File 'lib/appium_lib_core/device.rb', line 443
|
#take_element_screenshot(element, png_path) ⇒ File
Returns Path to the screenshot.
|
|
# File 'lib/appium_lib_core/device.rb', line 433
|
#terminate_app(app_id) ⇒ Boolean
Terminate the specified app.
|
|
# File 'lib/appium_lib_core/device.rb', line 131
|
#unlock ⇒ Object
Unlock the device
|
|
# File 'lib/appium_lib_core/device.rb', line 64
|
#update_settings(settings) ⇒ Object
Update Appium Settings for current test session
|
|
# File 'lib/appium_lib_core/device.rb', line 325
|