Class: Appium::Core::Base::Driver
- Inherits:
-
Selenium::WebDriver::Driver
- Object
- Selenium::WebDriver::Driver
- Appium::Core::Base::Driver
- Includes:
- HasLocation, HasNetworkConnection, HasRemoteStatus, Rotatable, SearchContext, TakesScreenshot, Waitable, Selenium::WebDriver::DriverExtensions::HasSessionId, Selenium::WebDriver::DriverExtensions::HasWebStorage, Selenium::WebDriver::DriverExtensions::UploadsFiles
- Defined in:
- lib/appium_lib_core/common/base/driver.rb
Constant Summary collapse
- AVAILABLE_METHODS =
[ :get, :head, :post, :put, :delete, :connect, :options, :trace, :patch ].freeze
Constants included from SearchContext
Constants included from Rotatable
Instance Attribute Summary collapse
-
#bridge ⇒ Object
readonly
Private API.
Instance Method Summary collapse
-
#activate_app(app_id) ⇒ Hash
Activate(Launch) the specified app.
-
#add_command(method:, url:, name:, &block) ⇒ Object
Define a new custom method to the driver so that you can define your own method for drivers/plugins in Appium 2.0.
-
#app_installed?(app_id) ⇒ Boolean
Check whether the specified app is installed on the device.
-
#app_state(app_id) ⇒ AppState::STATUS
(also: #query_app_state)
Get the status of an existing application on the device.
-
#app_strings(language = nil) ⇒ Hash
deprecated
Deprecated.
Use ‘mobile: getAppStrings’ extension instead.
-
#available_contexts ⇒ Array<String>
All usable contexts, as an array of strings.
-
#back ⇒ String
Get the device window’s size.
-
#background_app(duration = 0) ⇒ String
deprecated
Deprecated.
Use ‘mobile: backgroundApp’ extension instead.
-
#close_app ⇒ Object
deprecated
Deprecated.
Will be removed, or use ‘windows: closeApp’ extension instead for Windows.
- #compare_images(mode: :matchFeatures, first_image:, second_image:, options: nil) ⇒ Object
-
#context=(context = nil) ⇒ Object
(also: #set_context)
Change the context to the given context.
-
#convert_to_element(id) ⇒ ::Appium::Core::Element
Convert vanilla element response to ::Appium::Core::Element.
-
#current_context ⇒ String
The context currently being used.
-
#device_time(format = nil) ⇒ String
deprecated
Deprecated.
Use ‘mobile: getDeviceTime’ extension instead.
-
#execute_driver(script: '', type: 'webdriverio', timeout_ms: nil) ⇒ Appium::Core::Base::Device::ExecuteDriver::Result
Run a set of script against the current session, allowing execution of many commands in one Appium request.
-
#find_element_by_image(img_path) ⇒ ::Appium::Core::Element
Return an element if current view has a partial image.
-
#find_elements_by_image(img_path) ⇒ Array<::Appium::Core::Element>
Return elements if current view has a partial image.
- #find_image_occurrence(full_image:, partial_image:, visualize: false, threshold: nil, multiple: nil, match_neighbour_threshold: nil) ⇒ Object
- #get_images_similarity(first_image:, second_image:, visualize: false) ⇒ Object
-
#get_settings ⇒ Object
Get appium Settings for current test session.
-
#get_timeouts ⇒ Hash
For W3C.
-
#hide_keyboard(close_key = nil, strategy = nil) ⇒ Object
deprecated
Deprecated.
Use ‘mobile: hideKeyboard’ extension instead.
-
#ime ⇒ Appium::Core::Base::Driver::DeviceIME
deprecated
Deprecated.
Use ‘mobile: shell’ extension instead.
-
#ime_activate(ime_name) ⇒ Object
deprecated
Deprecated.
Use ‘mobile: shell’ extension instead.
-
#ime_activated ⇒ Boolean
deprecated
Deprecated.
Use ‘mobile: shell’ extension instead.
-
#ime_active_engine ⇒ Object
deprecated
Deprecated.
Use ‘mobile: shell’ extension instead.
-
#ime_available_engines ⇒ Object
deprecated
Deprecated.
Use ‘mobile: shell’ extension instead.
-
#ime_deactivate ⇒ Object
deprecated
Deprecated.
Use ‘mobile: shell’ extension instead.
-
#initialize(bridge: nil, listener: nil, **opts) ⇒ Driver
constructor
override.
-
#install_app(path, **options) ⇒ Object
Install the given app onto the device.
-
#key_action(async: false) ⇒ Object
Perform ‘key’ actions for W3C module.
-
#keyboard_shown? ⇒ Boolean
(also: #is_keyboard_shown)
deprecated
Deprecated.
Use ‘mobile: isKeyboardShown’ extension instead.
-
#launch_app ⇒ Object
deprecated
Deprecated.
Will be removed, or use ‘windows: launchApp’ extension instead for Windows.
-
#lock(duration = nil) ⇒ String
deprecated
Deprecated.
Use ‘mobile: lock’ extension instead.
-
#locked? ⇒ Boolean
(also: #device_locked?)
deprecated
Deprecated.
Use ‘mobile: isLocked’ extension instead.
-
#logs ⇒ Appium::Core::Logs
Get the device window’s logs.
-
#long_press_keycode(key, metastate: [], flags: []) ⇒ Object
deprecated
Deprecated.
Use ‘mobile: pressKey’ extension instead.
-
#match_images_features(first_image:, second_image:, detector_name: 'ORB', match_func: 'BruteForce', good_matches_factor: nil, visualize: false) ⇒ Object
Image Comparison.
- #multi_touch(actions) ⇒ Object
-
#perform_actions(data) ⇒ Object
Send multiple W3C action chains to server.
-
#press_keycode(key, metastate: [], flags: []) ⇒ Object
deprecated
Deprecated.
Use ‘mobile: pressKey’ extension instead.
-
#pull_file(path) ⇒ Base64-decoded
Pull a file from the remote device.
-
#pull_folder(path) ⇒ Base64-decoded
Pull a folder content from the remote 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
- #reset ⇒ Object deprecated Deprecated.
-
#session_capabilities ⇒ Selenium::WebDriver::Remote::Capabilities
Retrieve the capabilities of the specified session.
-
#sessions ⇒ [Hash]
Returns available sessions on the Appium server.
-
#settings ⇒ Object
Returns an instance of DriverSettings to call get/update.
-
#settings=(value) ⇒ Object
(also: #update_settings)
Update Appium Settings for current test session Alias of @driver.settings#update.
-
#shake ⇒ Object
deprecated
Deprecated.
Use ‘mobile: shake’ extension instead.
- #stop_and_save_recording_screen(file_path) ⇒ Object
- #stop_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT') ⇒ Object
-
#switch_to_default_context ⇒ Object
deprecated
Deprecated.
Use set context with proper context name instead.
-
#terminate_app(app_id, timeout: nil) ⇒ Boolean
Terminate the specified app.
-
#touch_actions(actions) ⇒ Object
touch actions.
-
#unlock ⇒ Object
deprecated
Deprecated.
Use ‘mobile: unlock’ extension instead.
-
#update_sending_request_to(protocol:, host:, port:, path:) ⇒ Object
Update
server_urland HTTP clients following this arguments, protocol, host, port and path. -
#window_rect ⇒ Selenium::WebDriver::Rectangle
Get the device window’s rect.
-
#window_size ⇒ Selenium::WebDriver::Dimension
Get the device window’s size.
-
#within_context(context, &block) ⇒ Object
Perform a block within the given context, then switch back to the starting context.
Methods included from Waitable
Methods included from HasNetworkConnection
#network_connection_type, #network_connection_type=
Methods included from HasLocation
#location, #location=, #set_location
Methods included from HasRemoteStatus
Methods included from TakesScreenshot
#element_screenshot_as, #save_element_screenshot, #save_screenshot, #save_viewport_screenshot, #screenshot_as
Methods included from SearchContext
Methods included from Rotatable
Constructor Details
#initialize(bridge: nil, listener: nil, **opts) ⇒ Driver
override
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 48 def initialize(bridge: nil, listener: nil, **opts) # rubocop:disable Lint/MissingSuper original_opts = opts.dup # For ::Appium::Core::Waitable @wait_timeout = opts.delete(:wait_timeout) @wait_interval = opts.delete(:wait_interval) # Selenium WebDriver attributes @devtools = nil @bidi = nil # in the selenium webdriver as well bridge ||= create_bridge(**opts) add_extensions(bridge.browser) @bridge = listener ? ::Appium::Support::EventFiringBridge.new(bridge, listener, **original_opts) : bridge end |
Instance Attribute Details
#bridge ⇒ Object (readonly)
Private API. Do not use this for general use. Used by flutter driver to get bridge for creating a new element
45 46 47 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 45 def bridge @bridge end |
Instance Method Details
#activate_app(app_id) ⇒ Hash
Activate(Launch) the specified app.
743 744 745 746 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 743 def activate_app(app_id) # TODO: use mobile command in the background? @bridge.activate_app(app_id) end |
#add_command(method:, url:, name:, &block) ⇒ Object
Define a new custom method to the driver so that you can define your own method for drivers/plugins in Appium 2.0. Appium 2.0 and its custom drivers/plugins allow you to define custom commands that are not part of W3C spec.
189 190 191 192 193 194 195 196 197 198 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 189 def add_command(method:, url:, name:, &block) unless AVAILABLE_METHODS.include? method raise ::Appium::Core::Error::ArgumentError, "Available method is either #{AVAILABLE_METHODS}" end # TODO: Remove this logger before Appium 2.0 release ::Appium::Logger.info '[Experimental] this method is experimental for Appium 2.0. This interface may change.' @bridge.add_command method: method, url: url, name: name, &block end |
#app_installed?(app_id) ⇒ Boolean
Check whether the specified app is installed on the device
731 732 733 734 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 731 def app_installed?(app_id) # TODO: use mobile command in the background? @bridge.app_installed?(app_id) end |
#app_state(app_id) ⇒ AppState::STATUS Also known as: query_app_state
Get the status of an existing application on the device. State:
:not_installed : The current application state cannot be determined/is unknown
:not_running : The application is not running
:running_in_background_suspended : The application is running in the background and is suspended
:running_in_background : The application is running in the background and is not suspended
:running_in_foreground : The application is running in the foreground
For more details: developer.apple.com/documentation/xctest/xcuiapplicationstate
784 785 786 787 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 784 def app_state(app_id) # TODO: use mobile command in the background? @bridge.app_state(app_id) end |
#app_strings(language = nil) ⇒ Hash
Use ‘mobile: getAppStrings’ extension instead.
Return the hash of all localization strings.
651 652 653 654 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 651 def app_strings(language = nil) ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getAppStrings' extension instead" @bridge.app_strings(language) end |
#available_contexts ⇒ Array<String>
Returns All usable contexts, as an array of strings.
465 466 467 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 465 def available_contexts @bridge.available_contexts end |
#back ⇒ String
Get the device window’s size.
934 935 936 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 934 def back navigate.back end |
#background_app(duration = 0) ⇒ String
Use ‘mobile: backgroundApp’ extension instead.
Backgrounds the app for a set number of seconds. This is a blocking application
668 669 670 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 668 def background_app(duration = 0) @bridge.background_app(duration) end |
#close_app ⇒ Object
Will be removed, or use ‘windows: closeApp’ extension instead for Windows.
Close an app on device
624 625 626 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 624 def close_app @bridge.close_app end |
#compare_images(mode: :matchFeatures, first_image:, second_image:, options: nil) ⇒ Object
1086 1087 1088 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 1086 def compare_images(mode: :matchFeatures, first_image:, second_image:, options: nil) @bridge.compare_images(mode: mode, first_image: first_image, second_image: second_image, options: ) end |
#context=(context = nil) ⇒ Object Also known as: set_context
Change the context to the given context.
477 478 479 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 477 def context=(context = nil) @bridge.set_context(context) end |
#convert_to_element(id) ⇒ ::Appium::Core::Element
Convert vanilla element response to ::Appium::Core::Element
1179 1180 1181 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 1179 def convert_to_element(id) @bridge.convert_to_element id end |
#current_context ⇒ String
Returns The context currently being used.
455 456 457 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 455 def current_context @bridge.current_context end |
#device_time(format = nil) ⇒ String
Use ‘mobile: getDeviceTime’ extension instead.
Get the time on the device
850 851 852 853 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 850 def device_time(format = nil) ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getDeviceTime' extension instead" @bridge.device_time(format) end |
#execute_driver(script: '', type: 'webdriverio', timeout_ms: nil) ⇒ Appium::Core::Base::Device::ExecuteDriver::Result
Run a set of script against the current session, allowing execution of many commands in one Appium request. Supports WebdriverIO API so far. Please read command API for more details about acceptable scripts and the output.
1165 1166 1167 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 1165 def execute_driver(script: '', type: 'webdriverio', timeout_ms: nil) @bridge.execute_driver(script: script, type: type, timeout_ms: timeout_ms) end |
#find_element_by_image(img_path) ⇒ ::Appium::Core::Element
Return an element if current view has a partial image. The logic depends on template matching by OpenCV. image-comparison
You can handle settings for the comparision following below. device-settings
1107 1108 1109 1110 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 1107 def find_element_by_image(img_path) template = Base64.strict_encode64 File.read img_path find_element :image, template end |
#find_elements_by_image(img_path) ⇒ Array<::Appium::Core::Element>
Return elements if current view has a partial image. The logic depends on template matching by OpenCV. image-comparison
You can handle settings for the comparision following below. device-settings
1130 1131 1132 1133 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 1130 def find_elements_by_image(img_path) template = Base64.strict_encode64 File.read img_path find_elements :image, template end |
#find_image_occurrence(full_image:, partial_image:, visualize: false, threshold: nil, multiple: nil, match_neighbour_threshold: nil) ⇒ Object
1072 1073 1074 1075 1076 1077 1078 1079 1080 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 1072 def find_image_occurrence(full_image:, partial_image:, visualize: false, threshold: nil, multiple: nil, match_neighbour_threshold: nil) @bridge.find_image_occurrence(full_image: full_image, partial_image: partial_image, visualize: visualize, threshold: threshold, multiple: multiple, match_neighbour_threshold: match_neighbour_threshold) end |
#get_images_similarity(first_image:, second_image:, visualize: false) ⇒ Object
1082 1083 1084 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 1082 def get_images_similarity(first_image:, second_image:, visualize: false) @bridge.get_images_similarity(first_image: first_image, second_image: second_image, visualize: visualize) end |
#get_settings ⇒ Object
Get appium Settings for current test session. Alias of @driver.settings.get
320 321 322 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 320 def get_settings settings.get end |
#get_timeouts ⇒ Hash
For W3C. Get the timeout related settings on the server side.
958 959 960 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 958 def get_timeouts @bridge.get_timeouts end |
#hide_keyboard(close_key = nil, strategy = nil) ⇒ Object
Use ‘mobile: hideKeyboard’ extension instead.
Hide the onscreen keyboard
282 283 284 285 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 282 def hide_keyboard(close_key = nil, strategy = nil) ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: hideKeyboard' extension instead" @bridge.hide_keyboard close_key, strategy end |
#ime ⇒ Appium::Core::Base::Driver::DeviceIME
Use ‘mobile: shell’ extension instead.
Returns an instance of DeviceIME
353 354 355 356 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 353 def ime ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: shell' extension instead" @ime ||= DeviceIME.new(@bridge) end |
#ime_activate(ime_name) ⇒ Object
Use ‘mobile: shell’ extension instead.
Android only. Make an engine that is available active.
368 369 370 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 368 def ime_activate(ime_name) ime.activate(ime_name) end |
#ime_activated ⇒ Boolean
Use ‘mobile: shell’ extension instead.
407 408 409 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 407 def ime_activated ime.activated? end |
#ime_active_engine ⇒ Object
Use ‘mobile: shell’ extension instead.
Android only. Get the name of the active IME engine.
392 393 394 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 392 def ime_active_engine ime.active_engine end |
#ime_available_engines ⇒ Object
Use ‘mobile: shell’ extension instead.
Android only. List all available input engines on the machine.
380 381 382 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 380 def ime_available_engines ime.available_engines end |
#ime_deactivate ⇒ Object
Use ‘mobile: shell’ extension instead.
Android only. De-activates the currently-active IME engine.
419 420 421 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 419 def ime_deactivate ime.deactivate end |
#install_app(path, **options) ⇒ Object
Install the given app onto the device. Each options can be snake-case or camel-case. Snake-cases will be converted to camel-case as options value.
Other parameters such as github.com/appium/appium-xcuitest-driver#mobile-installapp also can be set. Then, arguments in snake case will be camel case as its request parameters.
698 699 700 701 702 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 698 def install_app(path, **) # TODO: use mobile command in the background? = .transform_keys { |key| key.to_s.gsub(/_./) { |v| v[1].upcase } } unless .nil? @bridge.install_app(path, ) end |
#key_action(async: false) ⇒ Object
Perform ‘key’ actions for W3C module. Generate key pointer action here and users can use this via driver.key_action
-
www.selenium.dev/selenium/docs/api/rb/Selenium/WebDriver/ActionBuilder.html
-
www.selenium.dev/selenium/docs/api/rb/Selenium/WebDriver/KeyActions.html
The pointer type is ‘key’ by default in the Appium Ruby client. driver.action in Appium Ruby client has ‘pointer’ action by default. This method is a shortcut to set ‘key’ type. Hense this method is equal to driver.action(devices: [::Selenium::WebDriver::Interactions.key(‘keyboard’)]) as below example.
220 221 222 223 224 225 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 220 def key_action(async: false) @bridge.action( async: async, devices: [::Selenium::WebDriver::Interactions.key('keyboard')] ) end |
#keyboard_shown? ⇒ Boolean Also known as: is_keyboard_shown
Use ‘mobile: isKeyboardShown’ extension instead.
Get whether keyboard is displayed or not.
295 296 297 298 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 295 def keyboard_shown? ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: isKeyboardShown' extension instead" @bridge.is_keyboard_shown end |
#launch_app ⇒ Object
Will be removed, or use ‘windows: launchApp’ extension instead for Windows.
Start the simulator and application configured with desired capabilities
613 614 615 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 613 def launch_app @bridge.launch_app end |
#lock(duration = nil) ⇒ String
Use ‘mobile: lock’ extension instead.
Lock the device
237 238 239 240 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 237 def lock(duration = nil) ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: lock' extension instead" @bridge.lock(duration) end |
#locked? ⇒ Boolean Also known as: device_locked?
Use ‘mobile: isLocked’ extension instead.
Check current device status is weather locked or not
250 251 252 253 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 250 def locked? ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: isLocked' extension instead" @bridge.device_locked? end |
#logs ⇒ Appium::Core::Logs
Get the device window’s logs.
946 947 948 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 946 def logs @logs ||= Logs.new(@bridge) end |
#long_press_keycode(key, metastate: [], flags: []) ⇒ Object
Use ‘mobile: pressKey’ extension instead.
Long press keycode on the device. developer.android.com/reference/android/view/KeyEvent.html
601 602 603 604 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 601 def long_press_keycode(key, metastate: [], flags: []) ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: pressKey' extension instead" @bridge.long_press_keycode(key, metastate: , flags: flags) end |
#match_images_features(first_image:, second_image:, detector_name: 'ORB', match_func: 'BruteForce', good_matches_factor: nil, visualize: false) ⇒ Object
Image Comparison
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 1058 def match_images_features(first_image:, second_image:, detector_name: 'ORB', match_func: 'BruteForce', good_matches_factor: nil, visualize: false) @bridge.match_images_features(first_image: first_image, second_image: second_image, detector_name: detector_name, match_func: match_func, good_matches_factor: good_matches_factor, visualize: visualize) end |
#multi_touch(actions) ⇒ Object
860 861 862 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 860 def multi_touch(actions) @bridge.multi_touch(actions) end |
#perform_actions(data) ⇒ Object
Send multiple W3C action chains to server. Use @driver.action for single action chain.
@example: Zoom
f1 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger1')
f1.create_pointer_move(duration: 1, x: 200, y: 500,
origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f1.create_pointer_down(:left)
f1.create_pointer_move(duration: 1, x: 200, y: 200,
origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f1.create_pointer_up(:left)
f2 = ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'finger2')
f2.create_pointer_move(duration: 1, x: 200, y: 500,
origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f2.create_pointer_down(:left)
f2.create_pointer_move(duration: 1, x: 200, y: 800,
origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
f2.create_pointer_up(:left)
@driver.perform_actions [f1, f2] #=> 'nil' if the action succeed
890 891 892 893 894 895 896 897 898 899 900 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 890 def perform_actions(data) raise ::Appium::Core::Error::ArgumentError, "'#{data}' must be Array" unless data.is_a? Array # NOTE: 'add_input' in Selenium Ruby implementation has additional 'pause'. # This implementation is to avoid the additional pause. # https://github.com/SeleniumHQ/selenium/blob/64447d4b03f6986337d1ca8d8b6476653570bcc1/rb/lib/selenium/webdriver/common/action_builder.rb#L207 @bridge.send_actions data.map(&:encode).compact data.each(&:clear_actions) nil end |
#press_keycode(key, metastate: [], flags: []) ⇒ Object
Use ‘mobile: pressKey’ extension instead.
Press keycode on the device. developer.android.com/reference/android/view/KeyEvent.html
577 578 579 580 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 577 def press_keycode(key, metastate: [], flags: []) ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: pressKey' extension instead" @bridge.press_keycode(key, metastate: , flags: flags) end |
#pull_file(path) ⇒ Base64-decoded
Pull a file from the remote device. On Android the application under test should be built with debuggable flag enabled in order to get access to its container on the internal file system.
527 528 529 530 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 527 def pull_file(path) # TODO: use 'mobile: pullFile' internally @bridge.pull_file(path) end |
#pull_folder(path) ⇒ Base64-decoded
Pull a folder content from the remote device. On Android the application under test should be built with debuggable flag enabled in order to get access to its container on the internal file system.
553 554 555 556 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 553 def pull_folder(path) # TODO: use 'mobile: pullFolder' internally @bridge.pull_folder(path) end |
#push_file(path, filedata) ⇒ Object
Place a file in a specific location on the device. On Android, the application under test should be built with debuggable flag enabled in order to get access to its container on the internal file system.
498 499 500 501 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 498 def push_file(path, filedata) # TODO: use 'mobile: pushFile' internally @bridge.push_file(path, filedata) end |
#remove_app(app_id, keep_data: nil, timeout: nil) ⇒ Object
719 720 721 722 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 719 def remove_app(app_id, keep_data: nil, timeout: nil) # TODO: use mobile command in the background? @bridge.remove_app(app_id, keep_data: keep_data, timeout: timeout) end |
#reset ⇒ Object
Reset the device, relaunching the application.
635 636 637 638 639 640 641 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 635 def reset ::Appium::Logger.warn( '[DEPRECATION] reset is deprecated. Please use terminate_app and activate_app, ' \ 'or quit and create a new session instead.' ) @bridge.reset end |
#session_capabilities ⇒ Selenium::WebDriver::Remote::Capabilities
Retrieve the capabilities of the specified session. It’s almost same as @driver.capabilities but you can get more details.
1041 1042 1043 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 1041 def session_capabilities @bridge.session_capabilities end |
#sessions ⇒ [Hash]
Returns available sessions on the Appium server
1053 1054 1055 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 1053 def sessions @bridge.sessions end |
#settings ⇒ Object
Returns an instance of DriverSettings to call get/update.
308 309 310 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 308 def settings @settings ||= DriverSettings.new(@bridge) end |
#settings=(value) ⇒ Object Also known as: update_settings
Update Appium Settings for current test session Alias of @driver.settings#update
335 336 337 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 335 def settings=(value) settings.update(value) end |
#shake ⇒ Object
Use ‘mobile: shake’ extension instead.
Cause the device to shake
832 833 834 835 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 832 def shake ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: shake' extension instead" @bridge.shake end |
#stop_and_save_recording_screen(file_path) ⇒ Object
821 822 823 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 821 def stop_and_save_recording_screen(file_path) @bridge.stop_and_save_recording_screen(file_path) end |
#stop_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT') ⇒ Object
805 806 807 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 805 def stop_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT') @bridge.stop_recording_screen(remote_path: remote_path, user: user, pass: pass, method: method) end |
#switch_to_default_context ⇒ Object
Use set context with proper context name instead.
Change to the default context. This is equivalent to set_context nil.
444 445 446 447 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 444 def switch_to_default_context ::Appium::Logger.warn '[DEPRECATION] Please set proper context instead of calling this method.' @bridge.switch_to_default_context end |
#terminate_app(app_id, timeout: nil) ⇒ Boolean
Terminate the specified app.
760 761 762 763 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 760 def terminate_app(app_id, timeout: nil) # TODO: use mobile command in the background? @bridge.terminate_app(app_id, timeout: timeout) end |
#touch_actions(actions) ⇒ Object
touch actions
856 857 858 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 856 def touch_actions(actions) @bridge.touch_actions(actions) end |
#unlock ⇒ Object
Use ‘mobile: unlock’ extension instead.
Unlock the device
263 264 265 266 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 263 def unlock ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: unlock' extension instead" @bridge.unlock end |
#update_sending_request_to(protocol:, host:, port:, path:) ⇒ Object
Update server_url and HTTP clients following this arguments, protocol, host, port and path. After this method, @bridge.http will be a new instance following them instead of server_url which is set before creating session. If @bridge.http did not have update_sending_request_to method, this method returns immediately.
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 108 def update_sending_request_to(protocol:, host:, port:, path:) unless @bridge.http&.class&.method_defined? :update_sending_request_to ::Appium::Logger.warn "#{@bridge.http&.class} has no 'update_sending_request_to'. " \ 'It keeps current connection target.' return end @bridge.http&.update_sending_request_to(scheme: protocol, host: host, port: port, path: path) end |
#window_rect ⇒ Selenium::WebDriver::Rectangle
Get the device window’s rect.
924 925 926 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 924 def window_rect manage.window.rect end |
#window_size ⇒ Selenium::WebDriver::Dimension
Get the device window’s size.
910 911 912 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 910 def window_size manage.window.size end |
#within_context(context, &block) ⇒ Object
Perform a block within the given context, then switch back to the starting context.
433 434 435 |
# File 'lib/appium_lib_core/common/base/driver.rb', line 433 def within_context(context, &block) block_given? ? @bridge.within_context(context, &block) : @bridge.within_context(context) end |