appium_lib_core 4.1.0 → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +8 -0
- data/CHANGELOG.md +41 -277
- data/README.md +2 -1
- data/Rakefile +4 -0
- data/appium_lib_core.gemspec +2 -2
- data/ci-jobs/functional/run_appium.yml +2 -2
- data/ci-jobs/functional_test.yml +1 -1
- data/lib/appium_lib_core/android/device.rb +4 -4
- data/lib/appium_lib_core/common/base/bridge/mjsonwp.rb +28 -1
- data/lib/appium_lib_core/common/base/bridge/w3c.rb +25 -12
- data/lib/appium_lib_core/common/base/driver.rb +127 -23
- data/lib/appium_lib_core/common/base/has_location.rb +80 -0
- data/lib/appium_lib_core/common/base/http_default.rb +1 -3
- data/lib/appium_lib_core/common/base/remote_status.rb +31 -0
- data/lib/appium_lib_core/common/base/rotable.rb +54 -0
- data/lib/appium_lib_core/common/base/screenshot.rb +1 -1
- data/lib/appium_lib_core/common/base/search_context.rb +2 -0
- data/lib/appium_lib_core/common/base.rb +1 -0
- data/lib/appium_lib_core/common/device/image_comparison.rb +12 -4
- data/lib/appium_lib_core/common/device/orientation.rb +31 -0
- data/lib/appium_lib_core/common/error.rb +4 -1
- data/lib/appium_lib_core/driver.rb +14 -9
- data/lib/appium_lib_core/mac2/bridge.rb +25 -0
- data/lib/appium_lib_core/mac2/device/screen.rb +48 -0
- data/lib/appium_lib_core/mac2/device.rb +92 -0
- data/lib/appium_lib_core/mac2.rb +17 -0
- data/lib/appium_lib_core/patch.rb +53 -0
- data/lib/appium_lib_core/version.rb +2 -2
- data/release_notes.md +82 -0
- metadata +19 -10
data/README.md
CHANGED
@@ -11,6 +11,7 @@ This library wraps [selenium-webdriver](https://github.com/SeleniumHQ/selenium/w
|
|
11
11
|
# Documentation
|
12
12
|
|
13
13
|
- http://www.rubydoc.info/github/appium/ruby_lib_core
|
14
|
+
- You can find working API examples in test code, [test/functional](test/functional)
|
14
15
|
|
15
16
|
# Related library
|
16
17
|
- https://github.com/appium/ruby_lib
|
@@ -120,7 +121,7 @@ $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
|
|
120
121
|
$ ruby test.rb
|
121
122
|
```
|
122
123
|
|
123
|
-
More examples are in [test/functional](test/functional)
|
124
|
+
More examples are in [test/functional](test/functional)
|
124
125
|
|
125
126
|
### Capabilities
|
126
127
|
|
data/Rakefile
CHANGED
@@ -38,6 +38,7 @@ namespace :test do
|
|
38
38
|
namespace :unit do
|
39
39
|
desc('Run all iOS related unit tests in test directory')
|
40
40
|
Rake::TestTask.new(:ios) do |t|
|
41
|
+
ENV['UNIT_TEST'] = '1'
|
41
42
|
t.libs << 'test'
|
42
43
|
t.libs << 'lib'
|
43
44
|
t.test_files = FileList['test/unit/ios/**/*_test.rb']
|
@@ -45,6 +46,7 @@ namespace :test do
|
|
45
46
|
|
46
47
|
desc('Run all Android related unit tests in test directory')
|
47
48
|
Rake::TestTask.new(:android) do |t|
|
49
|
+
ENV['UNIT_TEST'] = '1'
|
48
50
|
t.libs << 'test'
|
49
51
|
t.libs << 'lib'
|
50
52
|
t.test_files = FileList['test/unit/android/**/*_test.rb']
|
@@ -52,6 +54,7 @@ namespace :test do
|
|
52
54
|
|
53
55
|
desc('Run all common related unit tests in test directory')
|
54
56
|
Rake::TestTask.new(:common) do |t|
|
57
|
+
ENV['UNIT_TEST'] = '1'
|
55
58
|
t.libs << 'test'
|
56
59
|
t.libs << 'lib'
|
57
60
|
t.test_files = FileList['test/unit/common/**/*_test.rb']
|
@@ -59,6 +62,7 @@ namespace :test do
|
|
59
62
|
|
60
63
|
desc('Run all Windows related unit tests in test directory')
|
61
64
|
Rake::TestTask.new(:windows) do |t|
|
65
|
+
ENV['UNIT_TEST'] = '1'
|
62
66
|
t.libs << 'test'
|
63
67
|
t.libs << 'lib'
|
64
68
|
t.test_files = FileList['test/unit/windows/**/*_test.rb']
|
data/appium_lib_core.gemspec
CHANGED
@@ -30,8 +30,8 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency 'yard', '~> 0.9.11'
|
31
31
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
32
32
|
spec.add_development_dependency 'minitest-reporters', '~> 1.1'
|
33
|
-
spec.add_development_dependency 'webmock', '~> 3.
|
34
|
-
spec.add_development_dependency 'rubocop', '1.
|
33
|
+
spec.add_development_dependency 'webmock', '~> 3.13.0'
|
34
|
+
spec.add_development_dependency 'rubocop', '1.12.0'
|
35
35
|
spec.add_development_dependency 'appium_thor', '~> 1.0'
|
36
36
|
spec.add_development_dependency 'pry'
|
37
37
|
spec.add_development_dependency 'pry-byebug'
|
@@ -1,8 +1,8 @@
|
|
1
1
|
steps:
|
2
2
|
- task: NodeTool@0
|
3
3
|
inputs:
|
4
|
-
versionSpec:
|
5
|
-
displayName: Install Node
|
4
|
+
versionSpec: 12.x
|
5
|
+
displayName: Install Node 12.x
|
6
6
|
- script: npm install -g appium@${APPIUM_VERSION}
|
7
7
|
displayName: Install appium beta
|
8
8
|
- script: npm install -g mjpeg-consumer
|
data/ci-jobs/functional_test.yml
CHANGED
@@ -4,7 +4,7 @@ parameters:
|
|
4
4
|
vmImageForIOS: 'macOS-10.15' # Not sure the reason, but macOS 10.14 instance raises no info.plist error
|
5
5
|
xcodeForIOS: 12.2
|
6
6
|
xcodeForTVOS: 12.2
|
7
|
-
androidSDK: 30
|
7
|
+
androidSDK: 29 # API Level 30 emulators are more unstable than 29
|
8
8
|
appiumVersion: 'beta'
|
9
9
|
ignoreVersionSkip: true
|
10
10
|
CI: true
|
@@ -290,16 +290,16 @@ module Appium
|
|
290
290
|
# @driver.finger_print 1
|
291
291
|
#
|
292
292
|
|
293
|
-
# @!method execute_cdp(cmd, params)
|
293
|
+
# @!method execute_cdp(cmd, **params)
|
294
294
|
# Execute Chrome Devtools protocol commands
|
295
295
|
# https://chromedevtools.github.io/devtools-protocol
|
296
296
|
#
|
297
297
|
# @param [String] cmd The name of command
|
298
|
-
# @
|
298
|
+
# @option params The parameter for the command as keyword options.
|
299
299
|
#
|
300
300
|
# @example
|
301
301
|
#
|
302
|
-
# @driver.execute_cdp 'Page.captureScreenshot',
|
302
|
+
# @driver.execute_cdp 'Page.captureScreenshot', quality: 50, format: 'jpeg'
|
303
303
|
# @driver.execute_cdp 'Page.getResourceTree'
|
304
304
|
#
|
305
305
|
|
@@ -415,7 +415,7 @@ module Appium
|
|
415
415
|
# SeleniumWebdriver could already define this method
|
416
416
|
return if method_defined? :execute_cdp
|
417
417
|
|
418
|
-
def execute_cdp(cmd, params
|
418
|
+
def execute_cdp(cmd, **params)
|
419
419
|
execute :chrome_send_command, {}, { cmd: cmd, params: params }
|
420
420
|
end
|
421
421
|
end
|
@@ -33,8 +33,24 @@ module Appium
|
|
33
33
|
include Device::TouchActions
|
34
34
|
include Device::ExecuteDriver
|
35
35
|
|
36
|
+
attr_reader :available_commands
|
37
|
+
|
38
|
+
def initialize(capabilities, session_id, **opts)
|
39
|
+
@available_commands = ::Appium::Core::Commands::MJSONWP::COMMANDS.dup
|
40
|
+
super(capabilities, session_id, **opts)
|
41
|
+
end
|
42
|
+
|
36
43
|
def commands(command)
|
37
|
-
|
44
|
+
@available_commands[command]
|
45
|
+
end
|
46
|
+
|
47
|
+
# command for Appium 2.0.
|
48
|
+
def add_command(method:, url:, name:, &block)
|
49
|
+
raise ::Appium::Core::Error::ArgumentError, "#{name} is already defined" if @available_commands.key? name
|
50
|
+
|
51
|
+
@available_commands[name] = [method, url]
|
52
|
+
|
53
|
+
::Appium::Core::Device.add_endpoint_method name, &block
|
38
54
|
end
|
39
55
|
|
40
56
|
# Returns all available sessions on the Appium server instance
|
@@ -42,6 +58,10 @@ module Appium
|
|
42
58
|
execute :get_all_sessions
|
43
59
|
end
|
44
60
|
|
61
|
+
def status
|
62
|
+
execute :status
|
63
|
+
end
|
64
|
+
|
45
65
|
# For Appium
|
46
66
|
def log_event(vendor, event)
|
47
67
|
execute :post_log_event, {}, { vendor: vendor, event: event }
|
@@ -74,6 +94,13 @@ module Appium
|
|
74
94
|
def convert_to_element(id)
|
75
95
|
::Selenium::WebDriver::Element.new self, element_id_from(id)
|
76
96
|
end
|
97
|
+
|
98
|
+
def set_location(lat, lon, alt = 0.0, speed: nil, satellites: nil)
|
99
|
+
loc = { latitude: lat, longitude: lon, altitude: alt }
|
100
|
+
loc[:speed] = speed unless speed.nil?
|
101
|
+
loc[:satellites] = satellites unless satellites.nil?
|
102
|
+
execute :set_location, {}, { location: loc }
|
103
|
+
end
|
77
104
|
end # class MJSONWP
|
78
105
|
end # class Bridge
|
79
106
|
end # class Base
|
@@ -32,9 +32,26 @@ module Appium
|
|
32
32
|
include Device::Device
|
33
33
|
include Device::TouchActions
|
34
34
|
include Device::ExecuteDriver
|
35
|
+
include Device::Orientation
|
36
|
+
|
37
|
+
attr_reader :available_commands
|
38
|
+
|
39
|
+
def initialize(capabilities, session_id, **opts)
|
40
|
+
@available_commands = ::Appium::Core::Commands::W3C::COMMANDS.dup
|
41
|
+
super(capabilities, session_id, **opts)
|
42
|
+
end
|
35
43
|
|
36
44
|
def commands(command)
|
37
|
-
|
45
|
+
@available_commands[command]
|
46
|
+
end
|
47
|
+
|
48
|
+
# command for Appium 2.0.
|
49
|
+
def add_command(method:, url:, name:, &block)
|
50
|
+
raise ::Appium::Core::Error::ArgumentError, "#{name} is already defined" if @available_commands.key? name
|
51
|
+
|
52
|
+
@available_commands[name] = [method, url]
|
53
|
+
|
54
|
+
::Appium::Core::Device.add_endpoint_method name, &block
|
38
55
|
end
|
39
56
|
|
40
57
|
# Returns all available sessions on the Appium server instance
|
@@ -42,6 +59,10 @@ module Appium
|
|
42
59
|
execute :get_all_sessions
|
43
60
|
end
|
44
61
|
|
62
|
+
def status
|
63
|
+
execute :status
|
64
|
+
end
|
65
|
+
|
45
66
|
# Perform touch actions for W3C module.
|
46
67
|
# Generate +touch+ pointer action here and users can use this via +driver.action+
|
47
68
|
# - https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/W3CActionBuilder.html
|
@@ -165,18 +186,10 @@ module Appium
|
|
165
186
|
|
166
187
|
# For Appium
|
167
188
|
# No implementation for W3C webdriver module
|
168
|
-
|
169
|
-
# It has below code as well. We should consider the same context in Selenium 4 as backward compatibility.
|
170
|
-
#
|
171
|
-
# def location=(loc)
|
172
|
-
# # note: Location = Struct.new(:latitude, :longitude, :altitude)
|
173
|
-
# raise TypeError, "expected #{Location}, got #{loc.inspect}:#{loc.class}" unless loc.is_a?(Location)
|
174
|
-
#
|
175
|
-
# @bridge.set_location loc.latitude, loc.longitude, loc.altitude
|
176
|
-
# end
|
177
|
-
#
|
178
|
-
def set_location(lat, lon, alt = 0.0)
|
189
|
+
def set_location(lat, lon, alt = 0.0, speed: nil, satellites: nil)
|
179
190
|
loc = { latitude: lat, longitude: lon, altitude: alt }
|
191
|
+
loc[:speed] = speed unless speed.nil?
|
192
|
+
loc[:satellites] = satellites unless satellites.nil?
|
180
193
|
execute :set_location, {}, { location: loc }
|
181
194
|
end
|
182
195
|
|
@@ -15,6 +15,9 @@
|
|
15
15
|
require 'base64'
|
16
16
|
require_relative 'search_context'
|
17
17
|
require_relative 'screenshot'
|
18
|
+
require_relative 'rotable'
|
19
|
+
require_relative 'remote_status'
|
20
|
+
require_relative 'has_location'
|
18
21
|
|
19
22
|
module Appium
|
20
23
|
module Core
|
@@ -22,12 +25,16 @@ module Appium
|
|
22
25
|
class Driver < ::Selenium::WebDriver::Driver
|
23
26
|
include ::Selenium::WebDriver::DriverExtensions::UploadsFiles
|
24
27
|
include ::Selenium::WebDriver::DriverExtensions::HasSessionId
|
25
|
-
include ::Selenium::WebDriver::DriverExtensions::Rotatable
|
26
28
|
include ::Selenium::WebDriver::DriverExtensions::HasRemoteStatus
|
27
29
|
include ::Selenium::WebDriver::DriverExtensions::HasWebStorage
|
30
|
+
include ::Selenium::WebDriver::DriverExtensions::HasNetworkConnection
|
31
|
+
include ::Selenium::WebDriver::DriverExtensions::HasTouchScreen
|
28
32
|
|
33
|
+
include ::Appium::Core::Base::Rotatable
|
29
34
|
include ::Appium::Core::Base::SearchContext
|
30
|
-
include ::Appium::Core::Base::
|
35
|
+
include ::Appium::Core::Base::TakesScreenshot
|
36
|
+
include ::Appium::Core::Base::HasRemoteStatus
|
37
|
+
include ::Appium::Core::Base::HasLocation
|
31
38
|
|
32
39
|
# Private API.
|
33
40
|
# Do not use this for general use. Used by flutter driver to get bridge for creating a new element
|
@@ -36,16 +43,6 @@ module Appium
|
|
36
43
|
def initialize(opts = {})
|
37
44
|
listener = opts.delete(:listener)
|
38
45
|
@bridge = ::Appium::Core::Base::Bridge.handshake(**opts)
|
39
|
-
if @bridge.dialect == :oss # MJSONWP
|
40
|
-
extend ::Selenium::WebDriver::DriverExtensions::HasTouchScreen
|
41
|
-
extend ::Selenium::WebDriver::DriverExtensions::HasLocation
|
42
|
-
extend ::Selenium::WebDriver::DriverExtensions::HasNetworkConnection
|
43
|
-
elsif @bridge.dialect == :w3c
|
44
|
-
# TODO: Only for Appium. Ideally, we'd like to remove the below like selenium-webdriver
|
45
|
-
extend ::Selenium::WebDriver::DriverExtensions::HasTouchScreen
|
46
|
-
extend ::Selenium::WebDriver::DriverExtensions::HasLocation
|
47
|
-
extend ::Selenium::WebDriver::DriverExtensions::HasNetworkConnection
|
48
|
-
end
|
49
46
|
super(@bridge, listener: listener)
|
50
47
|
end
|
51
48
|
|
@@ -58,6 +55,7 @@ module Appium
|
|
58
55
|
# Update +server_url+ and HTTP clients following this arguments, protocol, host, port and path.
|
59
56
|
# After this method, +@bridge.http+ will be a new instance following them instead of +server_url+ which is
|
60
57
|
# set before creating session.
|
58
|
+
# If +@bridge.http+ did not have +update_sending_request_to+ method, this method returns immediately.
|
61
59
|
#
|
62
60
|
# @example
|
63
61
|
#
|
@@ -66,10 +64,95 @@ module Appium
|
|
66
64
|
# driver.manage.timeouts.implicit_wait = 10 # @bridge.http is for 'https://example2.com:9000/wd/hub/'
|
67
65
|
#
|
68
66
|
def update_sending_request_to(protocol:, host:, port:, path:)
|
69
|
-
@bridge.http
|
70
|
-
|
71
|
-
|
72
|
-
|
67
|
+
unless @bridge.http&.class&.method_defined? :update_sending_request_to
|
68
|
+
::Appium::Logger.warn "#{@bridge.http&.class} has no 'update_sending_request_to'. " \
|
69
|
+
'It keeps current connection target.'
|
70
|
+
return
|
71
|
+
end
|
72
|
+
|
73
|
+
@bridge.http&.update_sending_request_to(scheme: protocol,
|
74
|
+
host: host,
|
75
|
+
port: port,
|
76
|
+
path: path)
|
77
|
+
end
|
78
|
+
|
79
|
+
AVAILABLE_METHODS = [
|
80
|
+
:get, :head, :post, :put, :delete,
|
81
|
+
:connect, :options, :trace, :patch
|
82
|
+
].freeze
|
83
|
+
# Define a new custom method to the driver so that you can define your own method for
|
84
|
+
# drivers/plugins in Appium 2.0. Appium 2.0 and its custom drivers/plugins allow you
|
85
|
+
# to define custom commands that are not part of W3C spec.
|
86
|
+
#
|
87
|
+
# @param [Symbol] method HTTP request method as https://www.w3.org/TR/webdriver/#endpoints
|
88
|
+
# @param [string] url The url to URL template as https://www.w3.org/TR/webdriver/#endpoints.
|
89
|
+
# +:session_id+ is the placeholder of 'session id'.
|
90
|
+
# Other place holders can be specified with +:+ prefix like +:id+.
|
91
|
+
# Then, the +:id+ will be replaced with a given value as the seconds argument of +execute+
|
92
|
+
# @param [Symbol] name The name of method that is called as the driver instance method.
|
93
|
+
# @param [Proc] block The block to involve as the method.
|
94
|
+
# Please define a method that has the same +name+ with arguments you want.
|
95
|
+
# The method must has +execute+ method. tHe +execute+ is calls the +url+
|
96
|
+
# with the given parameters.
|
97
|
+
# The first argument should be +name+ as symbol.
|
98
|
+
# The second argument should be hash. If keys in the hash matches +:+ prefix
|
99
|
+
# string in the given url, the matched string in the given url will be
|
100
|
+
# values in the hash.
|
101
|
+
# The third argument should be hash. The hash will be the request body.
|
102
|
+
# Please read examples below for more details.
|
103
|
+
# @raise [ArgumentError] If the given +name+ is already defined or +method+ are invalid value.
|
104
|
+
#
|
105
|
+
# @example
|
106
|
+
#
|
107
|
+
# @driver.add_command(
|
108
|
+
# method: :get,
|
109
|
+
# url: 'session/:session_id/path/to/custom/url',
|
110
|
+
# name: :test_command
|
111
|
+
# )
|
112
|
+
# # Send a GET request to 'session/<session id>/path/to/custom/url'
|
113
|
+
# @driver.test_command
|
114
|
+
#
|
115
|
+
#
|
116
|
+
# @driver.add_command(
|
117
|
+
# method: :post,
|
118
|
+
# url: 'session/:session_id/path/to/custom/url',
|
119
|
+
# name: :test_command
|
120
|
+
# ) do
|
121
|
+
# def test_command(argument)
|
122
|
+
# execute(:test_command, {}, { dummy: argument })
|
123
|
+
# end
|
124
|
+
# end
|
125
|
+
# # Send a POST request to 'session/<session id>/path/to/custom/url'
|
126
|
+
# # with body "{ dummy: 1 }" as JSON object. "1" is the argument.
|
127
|
+
# # ':session_id' in the given 'url' is replaced with current 'session id'.
|
128
|
+
# @driver.test_command(1)
|
129
|
+
#
|
130
|
+
#
|
131
|
+
# @driver.add_command(
|
132
|
+
# method: :post,
|
133
|
+
# url: 'session/:session_id/element/:id/custom/action',
|
134
|
+
# name: :test_action_command
|
135
|
+
# ) do
|
136
|
+
# def test_action_command(element_id, action)
|
137
|
+
# execute(:test_action_command, {id: element_id}, { dummy_action: action })
|
138
|
+
# end
|
139
|
+
# end
|
140
|
+
# # Send a POST request to 'session/<session id>/element/<element id>/custom/action'
|
141
|
+
# # with body "{ dummy_action: #{action} }" as JSON object. "action" is the seconds argument.
|
142
|
+
# # ':session_id' in the given url is replaced with current 'session id'.
|
143
|
+
# # ':id' in the given url is replaced with the given 'element_id'.
|
144
|
+
# e = @driver.find_element :accessibility_id, 'an element'
|
145
|
+
# @driver.test_action_command(e.ref, 'action')
|
146
|
+
#
|
147
|
+
def add_command(method:, url:, name:, &block)
|
148
|
+
unless AVAILABLE_METHODS.include? method
|
149
|
+
raise ::Appium::Core::Error::ArgumentError, "Available method is either #{AVAILABLE_METHODS}"
|
150
|
+
end
|
151
|
+
|
152
|
+
# TODO: Remove this logger
|
153
|
+
::Appium::Logger.info '[Experimental] this method is experimental for Appium 2.0. This interface may change.'
|
154
|
+
|
155
|
+
@bridge.add_command method: method, url: url, name: name, &block
|
73
156
|
end
|
74
157
|
|
75
158
|
### Methods for Appium
|
@@ -160,10 +243,24 @@ module Appium
|
|
160
243
|
@bridge = bridge
|
161
244
|
end
|
162
245
|
|
246
|
+
# Get appium Settings for current test session.
|
247
|
+
#
|
248
|
+
# @example
|
249
|
+
#
|
250
|
+
# @driver.settings.get
|
251
|
+
#
|
163
252
|
def get
|
164
253
|
@bridge.get_settings
|
165
254
|
end
|
166
255
|
|
256
|
+
# Update Appium Settings for current test session
|
257
|
+
#
|
258
|
+
# @param [Hash] settings Settings to update, keys are settings, values to value to set each setting to
|
259
|
+
#
|
260
|
+
# @example
|
261
|
+
#
|
262
|
+
# @driver.settings.update({'allowInvisibleElements': true})
|
263
|
+
#
|
167
264
|
def update(settings)
|
168
265
|
@bridge.update_settings(settings)
|
169
266
|
end
|
@@ -200,8 +297,8 @@ module Appium
|
|
200
297
|
#
|
201
298
|
# @example
|
202
299
|
#
|
203
|
-
# @driver.update_settings('allowInvisibleElements': true)
|
204
|
-
# @driver.settings.update('allowInvisibleElements': true)
|
300
|
+
# @driver.update_settings({ 'allowInvisibleElements': true })
|
301
|
+
# @driver.settings.update({ 'allowInvisibleElements': true })
|
205
302
|
# @driver.settings = { 'allowInvisibleElements': true }
|
206
303
|
#
|
207
304
|
def settings=(value)
|
@@ -239,6 +336,8 @@ module Appium
|
|
239
336
|
|
240
337
|
# Returns an instance of DeviceIME
|
241
338
|
#
|
339
|
+
# @return [Appium::Core::Base::Driver::DeviceIME]
|
340
|
+
#
|
242
341
|
# @example
|
243
342
|
#
|
244
343
|
# @driver.ime.activate engine: 'com.android.inputmethod.latin/.LatinIME'
|
@@ -289,6 +388,8 @@ module Appium
|
|
289
388
|
# @!method ime_activated
|
290
389
|
# Android only. Indicates whether IME input is active at the moment (not if it is available).
|
291
390
|
#
|
391
|
+
# @return [Boolean]
|
392
|
+
#
|
292
393
|
# @example
|
293
394
|
#
|
294
395
|
# @driver.ime_activated #=> True if IME is activated
|
@@ -853,7 +954,7 @@ module Appium
|
|
853
954
|
end
|
854
955
|
|
855
956
|
# Get the device window's logs.
|
856
|
-
# @return [
|
957
|
+
# @return [Appium::Core::Logs]
|
857
958
|
#
|
858
959
|
# @example
|
859
960
|
#
|
@@ -879,7 +980,7 @@ module Appium
|
|
879
980
|
# Retrieve the capabilities of the specified session.
|
880
981
|
# It's almost same as +@driver.capabilities+ but you can get more details.
|
881
982
|
#
|
882
|
-
# @return [Selenium::WebDriver::Remote::Capabilities]
|
983
|
+
# @return [Selenium::WebDriver::Remote::Capabilities, Selenium::WebDriver::Remote::W3C::Capabilities]
|
883
984
|
#
|
884
985
|
# @example
|
885
986
|
# @driver.session_capabilities
|
@@ -992,11 +1093,14 @@ module Appium
|
|
992
1093
|
visualize: visualize)
|
993
1094
|
end
|
994
1095
|
|
995
|
-
def find_image_occurrence(full_image:, partial_image:, visualize: false, threshold: nil
|
1096
|
+
def find_image_occurrence(full_image:, partial_image:, visualize: false, threshold: nil,
|
1097
|
+
multiple: nil, match_neighbour_threshold: nil)
|
996
1098
|
@bridge.find_image_occurrence(full_image: full_image,
|
997
1099
|
partial_image: partial_image,
|
998
1100
|
visualize: visualize,
|
999
|
-
threshold: threshold
|
1101
|
+
threshold: threshold,
|
1102
|
+
multiple: multiple,
|
1103
|
+
match_neighbour_threshold: match_neighbour_threshold)
|
1000
1104
|
end
|
1001
1105
|
|
1002
1106
|
def get_images_similarity(first_image:, second_image:, visualize: false)
|
@@ -1038,7 +1142,7 @@ module Appium
|
|
1038
1142
|
#
|
1039
1143
|
# @param [String] img_path A path to a partial image you'd like to find
|
1040
1144
|
#
|
1041
|
-
# @return [
|
1145
|
+
# @return [Array<Selenium::WebDriver::Element>]
|
1042
1146
|
#
|
1043
1147
|
# @example
|
1044
1148
|
#
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Appium
|
16
|
+
module Core
|
17
|
+
class Base
|
18
|
+
#
|
19
|
+
# @api private
|
20
|
+
#
|
21
|
+
module HasLocation
|
22
|
+
# Get the location of the device.
|
23
|
+
#
|
24
|
+
# @return [::Selenium::WebDriver::Location]
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
#
|
28
|
+
# driver.location #=> ::Selenium::WebDriver::Location.new(10, 10, 10)
|
29
|
+
#
|
30
|
+
def location
|
31
|
+
@bridge.location
|
32
|
+
end
|
33
|
+
|
34
|
+
# Set the location of the device.
|
35
|
+
#
|
36
|
+
# @param [::Selenium::WebDriver::Location] location Set the location.
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
#
|
40
|
+
# driver.location = ::Selenium::WebDriver::Location.new(10, 10, 10)
|
41
|
+
#
|
42
|
+
def location=(location)
|
43
|
+
unless location.is_a?(::Selenium::WebDriver::Location)
|
44
|
+
raise TypeError, "expected #{::Selenium::WebDriver::Location}, got #{location.inspect}:#{location.class}"
|
45
|
+
end
|
46
|
+
|
47
|
+
@bridge.set_location location.latitude, location.longitude, location.altitude
|
48
|
+
end
|
49
|
+
|
50
|
+
# Set the location of the device.
|
51
|
+
#
|
52
|
+
# @param [String, Number] latitude Set the latitude.
|
53
|
+
# @param [String, Number] longitude Set the longitude.
|
54
|
+
# @param [String, Number] altitude Set the altitude.
|
55
|
+
# @param [String, Number] speed Set the speed to apply the location on Android real devices
|
56
|
+
# in meters/second @since Appium 1.21.0 and in knots for emulators @since Appium 1.22.0.
|
57
|
+
# @param [String, Number] satellites Sets the number of geo satellites being tracked @since Appium 1.22.0.
|
58
|
+
# This number is respected on Emulators.
|
59
|
+
# @param [::Selenium::WebDriver::Location]
|
60
|
+
#
|
61
|
+
# @example
|
62
|
+
#
|
63
|
+
# driver.location = ::Selenium::WebDriver::Location.new(10, 10, 10)
|
64
|
+
#
|
65
|
+
def set_location(latitude, longitude, altitude, speed: nil, satellites: nil)
|
66
|
+
if speed.nil? && satellites.nil?
|
67
|
+
self.location = ::Selenium::WebDriver::Location.new(Float(latitude), Float(longitude), Float(altitude))
|
68
|
+
else
|
69
|
+
loc = ::Selenium::WebDriver::Location.new(Float(latitude), Float(longitude), Float(altitude))
|
70
|
+
|
71
|
+
speed = Float(speed) unless speed.nil?
|
72
|
+
satellites = Integer(satellites) unless satellites.nil?
|
73
|
+
|
74
|
+
@bridge.set_location loc.latitude, loc.longitude, loc.altitude, speed: speed, satellites: satellites
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -55,8 +55,6 @@ module Appium
|
|
55
55
|
def update_sending_request_to(scheme:, host:, port:, path:)
|
56
56
|
return @server_url unless validate_url_param(scheme, host, port, path)
|
57
57
|
|
58
|
-
::Appium::Logger.debug("[experimental] This feature, #{__method__}, is an experimental")
|
59
|
-
|
60
58
|
# Add / if 'path' does not have it
|
61
59
|
path = path.start_with?('/') ? path : "/#{path}"
|
62
60
|
path = path.end_with?('/') ? path : "#{path}/"
|
@@ -71,7 +69,7 @@ module Appium
|
|
71
69
|
return true unless [scheme, host, port, path].include?(nil)
|
72
70
|
|
73
71
|
message = "Given parameters are scheme: '#{scheme}', host: '#{host}', port: '#{port}', path: '#{path}'"
|
74
|
-
::Appium::Logger.
|
72
|
+
::Appium::Logger.debug(message)
|
75
73
|
false
|
76
74
|
end
|
77
75
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Appium
|
16
|
+
module Core
|
17
|
+
class Base
|
18
|
+
#
|
19
|
+
# @api private
|
20
|
+
#
|
21
|
+
|
22
|
+
module HasRemoteStatus
|
23
|
+
# Selenium binding has this ability only in Remote Binding,
|
24
|
+
# so this library has this method by own for safe.
|
25
|
+
def remote_status
|
26
|
+
bridge.status
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Appium
|
16
|
+
module Core
|
17
|
+
class Base
|
18
|
+
#
|
19
|
+
# @api private
|
20
|
+
#
|
21
|
+
|
22
|
+
module Rotatable
|
23
|
+
ORIENTATIONS = %i[landscape portrait].freeze
|
24
|
+
|
25
|
+
#
|
26
|
+
# Change the screen orientation
|
27
|
+
#
|
28
|
+
# @param [:landscape, :portrait] orientation
|
29
|
+
#
|
30
|
+
#
|
31
|
+
def rotation=(orientation)
|
32
|
+
unless ORIENTATIONS.include?(orientation)
|
33
|
+
raise ArgumentError, "expected #{ORIENTATIONS.inspect}, got #{orientation.inspect}"
|
34
|
+
end
|
35
|
+
|
36
|
+
bridge.screen_orientation = orientation.to_s.upcase
|
37
|
+
end
|
38
|
+
alias rotate rotation=
|
39
|
+
|
40
|
+
#
|
41
|
+
# Get the current screen orientation
|
42
|
+
#
|
43
|
+
# @return [:landscape, :portrait] orientation
|
44
|
+
#
|
45
|
+
# @api public
|
46
|
+
#
|
47
|
+
|
48
|
+
def orientation
|
49
|
+
bridge.screen_orientation.to_sym.downcase
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|