appium_lib_core 4.1.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +8 -0
- data/CHANGELOG.md +34 -275
- data/appium_lib_core.gemspec +1 -1
- 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 +10 -0
- data/lib/appium_lib_core/common/base/bridge/w3c.rb +7 -11
- data/lib/appium_lib_core/common/base/driver.rb +32 -21
- data/lib/appium_lib_core/common/base/has_location.rb +73 -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/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 +59 -0
- metadata +13 -4
data/appium_lib_core.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
32
32
|
spec.add_development_dependency 'minitest-reporters', '~> 1.1'
|
33
33
|
spec.add_development_dependency 'webmock', '~> 3.11.0'
|
34
|
-
spec.add_development_dependency 'rubocop', '1.
|
34
|
+
spec.add_development_dependency 'rubocop', '1.8.1'
|
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
|
@@ -42,6 +42,10 @@ module Appium
|
|
42
42
|
execute :get_all_sessions
|
43
43
|
end
|
44
44
|
|
45
|
+
def status
|
46
|
+
execute :status
|
47
|
+
end
|
48
|
+
|
45
49
|
# For Appium
|
46
50
|
def log_event(vendor, event)
|
47
51
|
execute :post_log_event, {}, { vendor: vendor, event: event }
|
@@ -74,6 +78,12 @@ module Appium
|
|
74
78
|
def convert_to_element(id)
|
75
79
|
::Selenium::WebDriver::Element.new self, element_id_from(id)
|
76
80
|
end
|
81
|
+
|
82
|
+
def set_location(lat, lon, alt = 0.0, speed: nil)
|
83
|
+
loc = { latitude: lat, longitude: lon, altitude: alt }
|
84
|
+
loc[:speed] = speed unless speed.nil?
|
85
|
+
execute :set_location, {}, { location: loc }
|
86
|
+
end
|
77
87
|
end # class MJSONWP
|
78
88
|
end # class Bridge
|
79
89
|
end # class Base
|
@@ -32,6 +32,7 @@ module Appium
|
|
32
32
|
include Device::Device
|
33
33
|
include Device::TouchActions
|
34
34
|
include Device::ExecuteDriver
|
35
|
+
include Device::Orientation
|
35
36
|
|
36
37
|
def commands(command)
|
37
38
|
::Appium::Core::Commands::W3C::COMMANDS[command]
|
@@ -42,6 +43,10 @@ module Appium
|
|
42
43
|
execute :get_all_sessions
|
43
44
|
end
|
44
45
|
|
46
|
+
def status
|
47
|
+
execute :status
|
48
|
+
end
|
49
|
+
|
45
50
|
# Perform touch actions for W3C module.
|
46
51
|
# Generate +touch+ pointer action here and users can use this via +driver.action+
|
47
52
|
# - https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/W3CActionBuilder.html
|
@@ -165,18 +170,9 @@ module Appium
|
|
165
170
|
|
166
171
|
# For Appium
|
167
172
|
# 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)
|
173
|
+
def set_location(lat, lon, alt = 0.0, speed: nil)
|
179
174
|
loc = { latitude: lat, longitude: lon, altitude: alt }
|
175
|
+
loc[:speed] = speed unless speed.nil?
|
180
176
|
execute :set_location, {}, { location: loc }
|
181
177
|
end
|
182
178
|
|
@@ -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,16 @@ 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)
|
73
77
|
end
|
74
78
|
|
75
79
|
### Methods for Appium
|
@@ -239,6 +243,8 @@ module Appium
|
|
239
243
|
|
240
244
|
# Returns an instance of DeviceIME
|
241
245
|
#
|
246
|
+
# @return [Appium::Core::Base::Driver::DeviceIME]
|
247
|
+
#
|
242
248
|
# @example
|
243
249
|
#
|
244
250
|
# @driver.ime.activate engine: 'com.android.inputmethod.latin/.LatinIME'
|
@@ -289,6 +295,8 @@ module Appium
|
|
289
295
|
# @!method ime_activated
|
290
296
|
# Android only. Indicates whether IME input is active at the moment (not if it is available).
|
291
297
|
#
|
298
|
+
# @return [Boolean]
|
299
|
+
#
|
292
300
|
# @example
|
293
301
|
#
|
294
302
|
# @driver.ime_activated #=> True if IME is activated
|
@@ -853,7 +861,7 @@ module Appium
|
|
853
861
|
end
|
854
862
|
|
855
863
|
# Get the device window's logs.
|
856
|
-
# @return [
|
864
|
+
# @return [Appium::Core::Logs]
|
857
865
|
#
|
858
866
|
# @example
|
859
867
|
#
|
@@ -879,7 +887,7 @@ module Appium
|
|
879
887
|
# Retrieve the capabilities of the specified session.
|
880
888
|
# It's almost same as +@driver.capabilities+ but you can get more details.
|
881
889
|
#
|
882
|
-
# @return [Selenium::WebDriver::Remote::Capabilities]
|
890
|
+
# @return [Selenium::WebDriver::Remote::Capabilities, Selenium::WebDriver::Remote::W3C::Capabilities]
|
883
891
|
#
|
884
892
|
# @example
|
885
893
|
# @driver.session_capabilities
|
@@ -992,11 +1000,14 @@ module Appium
|
|
992
1000
|
visualize: visualize)
|
993
1001
|
end
|
994
1002
|
|
995
|
-
def find_image_occurrence(full_image:, partial_image:, visualize: false, threshold: nil
|
1003
|
+
def find_image_occurrence(full_image:, partial_image:, visualize: false, threshold: nil,
|
1004
|
+
multiple: nil, match_neighbour_threshold: nil)
|
996
1005
|
@bridge.find_image_occurrence(full_image: full_image,
|
997
1006
|
partial_image: partial_image,
|
998
1007
|
visualize: visualize,
|
999
|
-
threshold: threshold
|
1008
|
+
threshold: threshold,
|
1009
|
+
multiple: multiple,
|
1010
|
+
match_neighbour_threshold: match_neighbour_threshold)
|
1000
1011
|
end
|
1001
1012
|
|
1002
1013
|
def get_images_similarity(first_image:, second_image:, visualize: false)
|
@@ -1038,7 +1049,7 @@ module Appium
|
|
1038
1049
|
#
|
1039
1050
|
# @param [String] img_path A path to a partial image you'd like to find
|
1040
1051
|
#
|
1041
|
-
# @return [
|
1052
|
+
# @return [Array<Selenium::WebDriver::Element>]
|
1042
1053
|
#
|
1043
1054
|
# @example
|
1044
1055
|
#
|
@@ -0,0 +1,73 @@
|
|
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 @since Appium 1.21.0.
|
56
|
+
# @param [::Selenium::WebDriver::Location]
|
57
|
+
#
|
58
|
+
# @example
|
59
|
+
#
|
60
|
+
# driver.location = ::Selenium::WebDriver::Location.new(10, 10, 10)
|
61
|
+
#
|
62
|
+
def set_location(latitude, longitude, altitude, speed: nil)
|
63
|
+
if speed.nil?
|
64
|
+
self.location = ::Selenium::WebDriver::Location.new(Float(latitude), Float(longitude), Float(altitude))
|
65
|
+
else
|
66
|
+
loc = ::Selenium::WebDriver::Location.new(Float(latitude), Float(longitude), Float(altitude))
|
67
|
+
@bridge.set_location loc.latitude, loc.longitude, loc.altitude, speed: Float(speed)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
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
|
@@ -29,6 +29,7 @@ require_relative 'device/clipboard_content_type'
|
|
29
29
|
require_relative 'device/device'
|
30
30
|
require_relative 'device/touch_actions'
|
31
31
|
require_relative 'device/execute_driver'
|
32
|
+
require_relative 'device/orientation'
|
32
33
|
|
33
34
|
# The following files have selenium-webdriver related stuff.
|
34
35
|
require_relative 'base/driver'
|
@@ -47,7 +47,7 @@ module Appium
|
|
47
47
|
# not available in the default OpenCV installation and have to be enabled manually
|
48
48
|
# before library compilation. The default detector name is 'ORB'.
|
49
49
|
# @param [String] match_func The name of the matching function. The default one is 'BruteForce'.
|
50
|
-
# @param [String] good_matches_factor The maximum count of "good" matches (e. g. with minimal distances).
|
50
|
+
# @param [String, nil] good_matches_factor The maximum count of "good" matches (e. g. with minimal distances).
|
51
51
|
# The default one is nil.
|
52
52
|
# @param [Bool] visualize Makes the endpoint to return an image, which contains the visualized result of
|
53
53
|
# the corresponding picture matching operation. This option is disabled by default.
|
@@ -94,7 +94,12 @@ module Appium
|
|
94
94
|
# are supported.
|
95
95
|
# @param [Bool] visualize Makes the endpoint to return an image, which contains the visualized result of
|
96
96
|
# the corresponding picture matching operation. This option is disabled by default.
|
97
|
-
# @param [Float] threshold [0.5] At what normalized threshold to reject
|
97
|
+
# @param [Float, nil] threshold [0.5] At what normalized threshold to reject
|
98
|
+
# @param [bool, nil] multiple Whether to enable the support of multiple image occurrences @since Appium 1.21.0.
|
99
|
+
# @param [integer, nil] match_neighbour_threshold The pixel distance between matches we consider to be part of
|
100
|
+
# the same template match @since Appium 1.21.0.
|
101
|
+
# This option is only considered if multiple matches mode is enabled.
|
102
|
+
# 10 pixels by default.
|
98
103
|
#
|
99
104
|
# @example
|
100
105
|
# @driver.find_image_occurrence full_image: "image data 1", partial_image: "image data 2"
|
@@ -102,12 +107,15 @@ module Appium
|
|
102
107
|
# visual = @@driver.find_image_occurrence full_image: image1, partial_image: image2, visualize: true
|
103
108
|
# File.write 'find_result_visual.png', Base64.decode64(visual['visualization']) # if the image is PNG
|
104
109
|
#
|
105
|
-
def find_image_occurrence(full_image:, partial_image:, visualize: false, threshold: nil
|
110
|
+
def find_image_occurrence(full_image:, partial_image:, visualize: false, threshold: nil,
|
111
|
+
multiple: nil, match_neighbour_threshold: nil)
|
106
112
|
raise "visualize should be #{MATCH_TEMPLATE[:visualize]}" unless MATCH_TEMPLATE[:visualize].member?(visualize)
|
107
113
|
|
108
114
|
options = {}
|
109
115
|
options[:visualize] = visualize
|
110
116
|
options[:threshold] = threshold unless threshold.nil?
|
117
|
+
options[:multiple] = multiple unless multiple.nil?
|
118
|
+
options[:matchNeighbourThreshold] = match_neighbour_threshold unless match_neighbour_threshold.nil?
|
111
119
|
|
112
120
|
compare_images(mode: :matchTemplate, first_image: full_image, second_image: partial_image, options: options)
|
113
121
|
end
|
@@ -144,7 +152,7 @@ module Appium
|
|
144
152
|
# +:matchFeatures is by default.
|
145
153
|
# @param [String] first_image An image data. All image formats, that OpenCV library itself accepts, are supported.
|
146
154
|
# @param [String] second_image An image data. All image formats, that OpenCV library itself accepts, are supported.
|
147
|
-
# @param [Hash] options The content of this dictionary depends on the actual +mode+ value.
|
155
|
+
# @param [Hash, nil] options The content of this dictionary depends on the actual +mode+ value.
|
148
156
|
# See the documentation on +appium-support+ module for more details.
|
149
157
|
# @return [Hash] The content of the resulting dictionary depends on the actual +mode+ and +options+ values.
|
150
158
|
# See the documentation on +appium-support+ module for more details.
|
@@ -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
|
+
module Device
|
19
|
+
module Orientation
|
20
|
+
def screen_orientation=(orientation)
|
21
|
+
execute :set_screen_orientation, {}, { orientation: orientation }
|
22
|
+
end
|
23
|
+
|
24
|
+
def screen_orientation
|
25
|
+
execute :get_screen_orientation
|
26
|
+
end
|
27
|
+
end # module Orientation
|
28
|
+
end # module Device
|
29
|
+
end # class Base
|
30
|
+
end # module Core
|
31
|
+
end # module Appium
|
@@ -27,6 +27,8 @@ module Appium
|
|
27
27
|
autoload :Xcuitest, 'appium_lib_core/ios_xcuitest'
|
28
28
|
end
|
29
29
|
|
30
|
+
autoload :Mac2, 'appium_lib_core/mac2'
|
31
|
+
|
30
32
|
autoload :Windows, 'appium_lib_core/windows'
|
31
33
|
|
32
34
|
# This options affects only client side as <code>:appium_lib</code> key.<br>
|
@@ -45,7 +47,7 @@ module Appium
|
|
45
47
|
@export_session = appium_lib_opts.fetch :export_session, false
|
46
48
|
@export_session_path = appium_lib_opts.fetch :export_session_path, default_tmp_appium_lib_session
|
47
49
|
|
48
|
-
@direct_connect = appium_lib_opts.fetch :direct_connect,
|
50
|
+
@direct_connect = appium_lib_opts.fetch :direct_connect, true
|
49
51
|
|
50
52
|
@port = appium_lib_opts.fetch :port, Driver::DEFAULT_APPIUM_PORT
|
51
53
|
|
@@ -175,7 +177,7 @@ module Appium
|
|
175
177
|
# - <code>directConnectPort</code>
|
176
178
|
# - <code>directConnectPath</code>
|
177
179
|
#
|
178
|
-
# Ignore them if this parameter is <code>false</code>. Defaults to
|
180
|
+
# Ignore them if this parameter is <code>false</code>. Defaults to true.
|
179
181
|
#
|
180
182
|
# @return [Bool]
|
181
183
|
attr_reader :direct_connect
|
@@ -435,7 +437,8 @@ module Appium
|
|
435
437
|
nil
|
436
438
|
end
|
437
439
|
|
438
|
-
# Returns the server's version info
|
440
|
+
# Returns the server's version info. This method calls +driver.remote_status+ internally
|
441
|
+
#
|
439
442
|
# @return [Hash]
|
440
443
|
#
|
441
444
|
# @example
|
@@ -449,18 +452,20 @@ module Appium
|
|
449
452
|
# }
|
450
453
|
# }
|
451
454
|
#
|
452
|
-
# Returns blank hash
|
455
|
+
# Returns blank hash in a case +driver.remote_status+ got an error
|
456
|
+
# such as Selenium Grid. It returns 500 error against 'remote_status'.
|
453
457
|
#
|
454
458
|
# @example
|
455
459
|
#
|
456
460
|
# @core.appium_server_version #=> {}
|
457
461
|
#
|
458
462
|
def appium_server_version
|
459
|
-
@driver.
|
460
|
-
rescue Selenium::WebDriver::Error::ServerError => e
|
461
|
-
raise ::Appium::Core::Error::ServerError unless e.message.include?('status code 500')
|
463
|
+
return {} if @driver.nil?
|
462
464
|
|
463
|
-
|
465
|
+
@driver.remote_status
|
466
|
+
rescue StandardError
|
467
|
+
# Ignore error case in a case the target appium server
|
468
|
+
# does not support `/status` API.
|
464
469
|
{}
|
465
470
|
end
|
466
471
|
|
@@ -526,7 +531,7 @@ module Appium
|
|
526
531
|
when :gecko
|
527
532
|
::Appium::Logger.debug('Gecko Driver for macOS')
|
528
533
|
when :mac2
|
529
|
-
::Appium::
|
534
|
+
::Appium::Core::Mac2::Bridge.for self
|
530
535
|
else
|
531
536
|
# no Mac specific extentions
|
532
537
|
::Appium::Logger.debug('macOS Native')
|
@@ -0,0 +1,25 @@
|
|
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
|
+
module Mac2
|
18
|
+
module Bridge
|
19
|
+
def self.for(target)
|
20
|
+
target.extend Appium::Core::Mac2::Device
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|