appium_lib_core 4.3.1 → 5.0.0.beta2

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.
@@ -95,6 +95,11 @@ module Appium
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
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
@@ -79,11 +79,7 @@ module Appium
79
79
  end
80
80
 
81
81
  def create_bridge_command(method, &block)
82
- ::Appium::Core::Base::Bridge::MJSONWP.class_eval do
83
- undef_method method if method_defined? method
84
- block_given? ? class_eval(&block) : define_method(method) { execute method }
85
- end
86
- ::Appium::Core::Base::Bridge::W3C.class_eval do
82
+ ::Appium::Core::Base::Bridge.class_eval do
87
83
  undef_method method if method_defined? method
88
84
  block_given? ? class_eval(&block) : define_method(method) { execute method }
89
85
  end
@@ -368,10 +368,10 @@ module Appium
368
368
 
369
369
  begin
370
370
  # included https://github.com/SeleniumHQ/selenium/blob/43f8b3f66e7e01124eff6a5805269ee441f65707/rb/lib/selenium/webdriver/remote/driver.rb#L29
371
- @driver = ::Appium::Core::Base::Driver.new(http_client: @http_client,
372
- desired_capabilities: @caps,
373
- url: @custom_url,
374
- listener: @listener)
371
+ @driver = ::Appium::Core::Base::Driver.new(listener: @listener,
372
+ http_client: @http_client,
373
+ desired_capabilities: @caps,
374
+ url: @custom_url)
375
375
 
376
376
  if @direct_connect
377
377
  d_c = DirectConnections.new(@driver.capabilities)
@@ -437,7 +437,8 @@ module Appium
437
437
  nil
438
438
  end
439
439
 
440
- # Returns the server's version info
440
+ # Returns the server's version info. This method calls +driver.remote_status+ internally
441
+ #
441
442
  # @return [Hash]
442
443
  #
443
444
  # @example
@@ -451,18 +452,20 @@ module Appium
451
452
  # }
452
453
  # }
453
454
  #
454
- # Returns blank hash for Selenium Grid since 'remote_status' gets 500 error
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'.
455
457
  #
456
458
  # @example
457
459
  #
458
460
  # @core.appium_server_version #=> {}
459
461
  #
460
462
  def appium_server_version
461
- @driver.remote_status
462
- rescue Selenium::WebDriver::Error::ServerError => e
463
- raise ::Appium::Core::Error::ServerError unless e.message.include?('status code 500')
463
+ return {} if @driver.nil?
464
464
 
465
- # driver.remote_status returns 500 error for using selenium grid
465
+ @driver.remote_status
466
+ rescue StandardError
467
+ # Ignore error case in a case the target appium server
468
+ # does not support `/status` API.
466
469
  {}
467
470
  end
468
471
 
@@ -12,16 +12,12 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- # rubocop:disable Style/ClassAndModuleChildren
16
15
  module Appium
17
16
  module Core
18
17
  # Implement useful features for element.
19
18
  # Patch for Selenium Webdriver.
20
- class Selenium::WebDriver::Element
21
- # To extend Appium related SearchContext into ::Selenium::WebDriver::Element
19
+ class Element < ::Selenium::WebDriver::Element
22
20
  include ::Appium::Core::Base::SearchContext
23
-
24
- # TODO: Probably can remove own TakesScreenshot since Selenium 4
25
21
  include ::Appium::Core::Base::TakesScreenshot
26
22
 
27
23
  # Returns the value of attributes like below. Read each platform to know more details.
@@ -152,7 +148,6 @@ module Appium
152
148
  end
153
149
  File.open(png_path, 'wb') { |f| f << screenshot_as(:png) }
154
150
  end
155
- end
151
+ end # class Element
156
152
  end # module Core
157
153
  end # module Appium
158
- # rubocop:enable Style/ClassAndModuleChildren
@@ -21,7 +21,7 @@ module Appium
21
21
  # will trigger as soon as the file is required. in contrast a method
22
22
  # will trigger only when invoked.
23
23
  def self.patch_webdriver_element
24
- ::Selenium::WebDriver::Element.class_eval do
24
+ ::Appium::Core::Element.class_eval do
25
25
  # Cross platform way of entering text into a textfield
26
26
  def type(text, driver)
27
27
  driver.execute_script %(au.getElement('#{ref}').setValue('#{text}');)
@@ -14,7 +14,7 @@
14
14
 
15
15
  module Appium
16
16
  module Core
17
- VERSION = '4.3.1' unless defined? ::Appium::Core::VERSION
18
- DATE = '2021-02-07' unless defined? ::Appium::Core::DATE
17
+ VERSION = '5.0.0.beta2' unless defined? ::Appium::Core::VERSION
18
+ DATE = '2021-04-13' unless defined? ::Appium::Core::DATE
19
19
  end
20
20
  end
data/release_notes.md CHANGED
@@ -1,3 +1,23 @@
1
+ #### v4.5.0 2021-03-14
2
+
3
+ - [656230e](https://github.com/appium/ruby_lib_core/commit/656230e688ed86414c06efaa73bce7359933cc91) Release 4.5.0
4
+ - [a0a3cfc](https://github.com/appium/ruby_lib_core/commit/a0a3cfc71783bed3d1b0e7afbf6bc0a27bf60a48) feat: add speed option (#318)
5
+ - [16b4f09](https://github.com/appium/ruby_lib_core/commit/16b4f0991deb639314857c3cbece1e4d00393646) feat: add multiple and match_neighbour_threshold (#313)
6
+ - [d195a5b](https://github.com/appium/ruby_lib_core/commit/d195a5ba48c2e1a7229e0145eac616fd886c1ee0) ci: use node 12
7
+
8
+
9
+ #### v4.4.1 2021-02-15
10
+
11
+ - [dc34419](https://github.com/appium/ruby_lib_core/commit/dc34419dfcc4dd8d499a6407d45ab3efe70c2445) Release 4.4.1
12
+ - [3085048](https://github.com/appium/ruby_lib_core/commit/3085048b4816e3415017ebb188e653c8e229a05e) chore: return {} in nil case as well
13
+
14
+
15
+ #### v4.4.0 2021-02-13
16
+
17
+ - [06c68fb](https://github.com/appium/ruby_lib_core/commit/06c68fbe3ffdbb7b068d2f71ad6841c66dbabf8f) Release 4.4.0
18
+ - [3c54ae2](https://github.com/appium/ruby_lib_core/commit/3c54ae25d9a334f3690c94ce8a59a5c6a4bacd20) feat: always return {} in appium_server_version for errors (#311)
19
+
20
+
1
21
  #### v4.3.1 2021-02-07
2
22
 
3
23
  - [1f4d52c](https://github.com/appium/ruby_lib_core/commit/1f4d52cc915783cf89cf4b8ca5a21bd1af5403e0) Release 4.3.1
data/script/commands.rb CHANGED
@@ -18,26 +18,18 @@ require './lib/appium_lib_core'
18
18
  module Script
19
19
  class CommandsChecker
20
20
  attr_reader :spec_commands,
21
- :implemented_mjsonwp_commands, :implemented_w3c_commands, :implemented_core_commands,
22
- :webdriver_oss_commands, :webdriver_w3c_commands
21
+ :implemented_w3c_commands, :implemented_core_commands,
22
+ :webdriver_w3c_commands
23
23
 
24
24
  # Set commands implemented in this core library.
25
25
  #
26
- # - implemented_mjsonwp_commands: All commands include ::Selenium::WebDriver::Remote::OSS::Bridge::COMMANDS
27
- # - implemented_w3c_commands: All commands include ::Selenium::WebDriver::Remote::W3C::Bridge::COMMANDS
26
+ # - implemented_w3c_commands: All commands include ::Selenium::WebDriver::Remote::Bridge::COMMANDS
28
27
  # - implemented_core_commands: All commands except for selenium-webdriver's commands
29
- # - webdriver_oss_commands: ::Selenium::WebDriver::Remote::OSS::Bridge::COMMANDS
30
- # - webdriver_w3c_commands: ::Selenium::WebDriver::Remote::W3C::Bridge::COMMANDS
31
28
  #
32
29
  def initialize
33
30
  @spec_commands = nil
34
31
 
35
- @implemented_mjsonwp_commands = convert_driver_commands Appium::Core::Commands::MJSONWP::COMMANDS
36
- @implemented_w3c_commands = convert_driver_commands Appium::Core::Commands::W3C::COMMANDS
37
32
  @implemented_core_commands = convert_driver_commands Appium::Core::Commands::COMMANDS
38
-
39
- @webdriver_oss_commands = convert_driver_commands Appium::Core::Base::Commands::OSS
40
- @webdriver_w3c_commands = convert_driver_commands Appium::Core::Base::Commands::W3C
41
33
  end
42
34
 
43
35
  # Get the bellow url's file.
@@ -80,18 +72,6 @@ module Script
80
72
  end
81
73
  end
82
74
 
83
- # All commands which haven't been implemented in ruby core library yet.
84
- # @return [Hash]
85
- #
86
- def all_diff_commands_mjsonwp
87
- result = compare_commands(@spec_commands, @implemented_mjsonwp_commands)
88
-
89
- white_list.each { |v| result.delete v }
90
- w3c_spec.each { |v| result.delete v }
91
-
92
- result
93
- end
94
-
95
75
  # All commands which haven't been implemented in ruby core library yet.
96
76
  # @return [Hash]
97
77
  #
@@ -111,20 +91,6 @@ module Script
111
91
  result
112
92
  end
113
93
 
114
- def diff_webdriver_oss
115
- result = compare_commands(@spec_commands, @webdriver_oss_commands)
116
- white_list.each { |v| result.delete v }
117
- w3c_spec.each { |v| result.delete v }
118
- result
119
- end
120
-
121
- def diff_webdriver_w3c
122
- result = compare_commands(@spec_commands, @webdriver_w3c_commands)
123
- white_list.each { |v| result.delete v }
124
- mjsonwp_spec.each { |v| result.delete v }
125
- result
126
- end
127
-
128
94
  def compare_commands(command1, with_command2)
129
95
  return {} if command1.nil?
130
96
  return command1 if with_command2.nil?
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_lib_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.1
4
+ version: 5.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuaki MATSUO
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-08 00:00:00.000000000 Z
11
+ date: 2021-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '3.14'
20
- - - ">="
17
+ - - '='
21
18
  - !ruby/object:Gem::Version
22
- version: 3.14.1
19
+ version: 4.0.0.beta2
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '3.14'
30
- - - ">="
24
+ - - '='
31
25
  - !ruby/object:Gem::Version
32
- version: 3.14.1
26
+ version: 4.0.0.beta2
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: faye-websocket
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -120,28 +114,28 @@ dependencies:
120
114
  requirements:
121
115
  - - "~>"
122
116
  - !ruby/object:Gem::Version
123
- version: 3.11.0
117
+ version: 3.12.1
124
118
  type: :development
125
119
  prerelease: false
126
120
  version_requirements: !ruby/object:Gem::Requirement
127
121
  requirements:
128
122
  - - "~>"
129
123
  - !ruby/object:Gem::Version
130
- version: 3.11.0
124
+ version: 3.12.1
131
125
  - !ruby/object:Gem::Dependency
132
126
  name: rubocop
133
127
  requirement: !ruby/object:Gem::Requirement
134
128
  requirements:
135
129
  - - '='
136
130
  - !ruby/object:Gem::Version
137
- version: 1.8.1
131
+ version: 1.12.0
138
132
  type: :development
139
133
  prerelease: false
140
134
  version_requirements: !ruby/object:Gem::Requirement
141
135
  requirements:
142
136
  - - '='
143
137
  - !ruby/object:Gem::Version
144
- version: 1.8.1
138
+ version: 1.12.0
145
139
  - !ruby/object:Gem::Dependency
146
140
  name: appium_thor
147
141
  requirement: !ruby/object:Gem::Requirement
@@ -262,20 +256,17 @@ files:
262
256
  - lib/appium_lib_core/common.rb
263
257
  - lib/appium_lib_core/common/base.rb
264
258
  - lib/appium_lib_core/common/base/bridge.rb
265
- - lib/appium_lib_core/common/base/bridge/mjsonwp.rb
266
- - lib/appium_lib_core/common/base/bridge/w3c.rb
267
259
  - lib/appium_lib_core/common/base/capabilities.rb
268
- - lib/appium_lib_core/common/base/command.rb
269
260
  - lib/appium_lib_core/common/base/driver.rb
261
+ - lib/appium_lib_core/common/base/has_location.rb
262
+ - lib/appium_lib_core/common/base/has_network_connection.rb
270
263
  - lib/appium_lib_core/common/base/http_default.rb
271
264
  - lib/appium_lib_core/common/base/platform.rb
265
+ - lib/appium_lib_core/common/base/remote_status.rb
272
266
  - lib/appium_lib_core/common/base/rotable.rb
273
267
  - lib/appium_lib_core/common/base/screenshot.rb
274
268
  - lib/appium_lib_core/common/base/search_context.rb
275
269
  - lib/appium_lib_core/common/command.rb
276
- - lib/appium_lib_core/common/command/common.rb
277
- - lib/appium_lib_core/common/command/mjsonwp.rb
278
- - lib/appium_lib_core/common/command/w3c.rb
279
270
  - lib/appium_lib_core/common/device/app_management.rb
280
271
  - lib/appium_lib_core/common/device/app_state.rb
281
272
  - lib/appium_lib_core/common/device/battery_status.rb
@@ -304,6 +295,7 @@ files:
304
295
  - lib/appium_lib_core/common/ws/websocket.rb
305
296
  - lib/appium_lib_core/device.rb
306
297
  - lib/appium_lib_core/driver.rb
298
+ - lib/appium_lib_core/element.rb
307
299
  - lib/appium_lib_core/ios.rb
308
300
  - lib/appium_lib_core/ios/device.rb
309
301
  - lib/appium_lib_core/ios/device/clipboard.rb
@@ -320,7 +312,6 @@ files:
320
312
  - lib/appium_lib_core/mac2/bridge.rb
321
313
  - lib/appium_lib_core/mac2/device.rb
322
314
  - lib/appium_lib_core/mac2/device/screen.rb
323
- - lib/appium_lib_core/patch.rb
324
315
  - lib/appium_lib_core/version.rb
325
316
  - lib/appium_lib_core/windows.rb
326
317
  - lib/appium_lib_core/windows/bridge.rb
@@ -340,12 +331,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
340
331
  requirements:
341
332
  - - ">="
342
333
  - !ruby/object:Gem::Version
343
- version: '2.4'
334
+ version: '2.5'
344
335
  required_rubygems_version: !ruby/object:Gem::Requirement
345
336
  requirements:
346
- - - ">="
337
+ - - ">"
347
338
  - !ruby/object:Gem::Version
348
- version: '0'
339
+ version: 1.3.1
349
340
  requirements: []
350
341
  rubygems_version: 3.1.2
351
342
  signing_key:
@@ -1,81 +0,0 @@
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
- class Bridge
19
- class MJSONWP < ::Selenium::WebDriver::Remote::OSS::Bridge
20
- include Device::DeviceLock
21
- include Device::Keyboard
22
- include Device::ImeActions
23
- include Device::Setting
24
- include Device::Context
25
- include Device::Value
26
- include Device::FileManagement
27
- include Device::KeyEvent
28
- include Device::ImageComparison
29
- include Device::AppManagement
30
- include Device::AppState
31
- include Device::ScreenRecord::Command
32
- include Device::Device
33
- include Device::TouchActions
34
- include Device::ExecuteDriver
35
-
36
- def commands(command)
37
- ::Appium::Core::Commands::MJSONWP::COMMANDS[command]
38
- end
39
-
40
- # Returns all available sessions on the Appium server instance
41
- def sessions
42
- execute :get_all_sessions
43
- end
44
-
45
- # For Appium
46
- def log_event(vendor, event)
47
- execute :post_log_event, {}, { vendor: vendor, event: event }
48
- end
49
-
50
- # For Appium
51
- def log_events(type = nil)
52
- args = {}
53
- args['type'] = type unless type.nil?
54
-
55
- execute :get_log_events, {}, args
56
- end
57
-
58
- def take_element_screenshot(element)
59
- execute :take_element_screenshot, id: element.ref
60
- end
61
-
62
- def take_viewport_screenshot
63
- # TODO: this hasn't been supported by Espresso driver
64
- execute_script('mobile: viewportScreenshot')
65
- end
66
-
67
- def send_actions(_data)
68
- raise Error::UnsupportedOperationError, '#send_actions has not been supported in MJSONWP'
69
- end
70
-
71
- # For Appium
72
- # @param [Hash] id The id which can get as a response from server
73
- # @return [::Selenium::WebDriver::Element]
74
- def convert_to_element(id)
75
- ::Selenium::WebDriver::Element.new self, element_id_from(id)
76
- end
77
- end # class MJSONWP
78
- end # class Bridge
79
- end # class Base
80
- end # module Core
81
- end # module Appium