appium_lib_core 4.5.0 → 5.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/unittest.yml +2 -2
  3. data/CHANGELOG.md +12 -5
  4. data/README.md +2 -1
  5. data/appium_lib_core.gemspec +4 -4
  6. data/lib/appium_lib_core.rb +2 -5
  7. data/lib/appium_lib_core/android/device/auth_finger_print.rb +2 -1
  8. data/lib/appium_lib_core/common/base.rb +0 -3
  9. data/lib/appium_lib_core/common/base/bridge.rb +284 -89
  10. data/lib/appium_lib_core/common/base/capabilities.rb +3 -3
  11. data/lib/appium_lib_core/common/base/{command.rb → device_ime.rb} +32 -7
  12. data/lib/appium_lib_core/common/base/driver.rb +128 -70
  13. data/lib/appium_lib_core/common/base/driver_settings.rb +51 -0
  14. data/lib/appium_lib_core/common/base/has_network_connection.rb +56 -0
  15. data/lib/appium_lib_core/common/base/rotable.rb +1 -1
  16. data/lib/appium_lib_core/common/base/search_context.rb +9 -4
  17. data/lib/appium_lib_core/common/command.rb +259 -4
  18. data/lib/appium_lib_core/common/device/keyevent.rb +4 -4
  19. data/lib/appium_lib_core/common/error.rb +4 -1
  20. data/lib/appium_lib_core/common/log.rb +4 -1
  21. data/lib/appium_lib_core/device.rb +1 -5
  22. data/lib/appium_lib_core/driver.rb +3 -4
  23. data/lib/appium_lib_core/{patch.rb → element.rb} +2 -7
  24. data/lib/appium_lib_core/ios/uiautomation/patch.rb +1 -1
  25. data/lib/appium_lib_core/version.rb +2 -2
  26. data/release_notes.md +14 -0
  27. data/script/commands.rb +3 -37
  28. metadata +21 -30
  29. data/lib/appium_lib_core/common/base/bridge/mjsonwp.rb +0 -91
  30. data/lib/appium_lib_core/common/base/bridge/w3c.rb +0 -248
  31. data/lib/appium_lib_core/common/command/common.rb +0 -110
  32. data/lib/appium_lib_core/common/command/mjsonwp.rb +0 -28
  33. data/lib/appium_lib_core/common/command/w3c.rb +0 -56
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.5.0
4
+ version: 5.0.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuaki MATSUO
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2021-06-12 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.beta4
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.beta4
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.13.0
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.13.0
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,12 +256,12 @@ 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
260
+ - lib/appium_lib_core/common/base/device_ime.rb
269
261
  - lib/appium_lib_core/common/base/driver.rb
262
+ - lib/appium_lib_core/common/base/driver_settings.rb
270
263
  - lib/appium_lib_core/common/base/has_location.rb
264
+ - lib/appium_lib_core/common/base/has_network_connection.rb
271
265
  - lib/appium_lib_core/common/base/http_default.rb
272
266
  - lib/appium_lib_core/common/base/platform.rb
273
267
  - lib/appium_lib_core/common/base/remote_status.rb
@@ -275,9 +269,6 @@ files:
275
269
  - lib/appium_lib_core/common/base/screenshot.rb
276
270
  - lib/appium_lib_core/common/base/search_context.rb
277
271
  - lib/appium_lib_core/common/command.rb
278
- - lib/appium_lib_core/common/command/common.rb
279
- - lib/appium_lib_core/common/command/mjsonwp.rb
280
- - lib/appium_lib_core/common/command/w3c.rb
281
272
  - lib/appium_lib_core/common/device/app_management.rb
282
273
  - lib/appium_lib_core/common/device/app_state.rb
283
274
  - lib/appium_lib_core/common/device/battery_status.rb
@@ -306,6 +297,7 @@ files:
306
297
  - lib/appium_lib_core/common/ws/websocket.rb
307
298
  - lib/appium_lib_core/device.rb
308
299
  - lib/appium_lib_core/driver.rb
300
+ - lib/appium_lib_core/element.rb
309
301
  - lib/appium_lib_core/ios.rb
310
302
  - lib/appium_lib_core/ios/device.rb
311
303
  - lib/appium_lib_core/ios/device/clipboard.rb
@@ -322,7 +314,6 @@ files:
322
314
  - lib/appium_lib_core/mac2/bridge.rb
323
315
  - lib/appium_lib_core/mac2/device.rb
324
316
  - lib/appium_lib_core/mac2/device/screen.rb
325
- - lib/appium_lib_core/patch.rb
326
317
  - lib/appium_lib_core/version.rb
327
318
  - lib/appium_lib_core/windows.rb
328
319
  - lib/appium_lib_core/windows/bridge.rb
@@ -334,7 +325,7 @@ homepage: https://github.com/appium/ruby_lib_core/
334
325
  licenses:
335
326
  - Apache-2.0
336
327
  metadata: {}
337
- post_install_message:
328
+ post_install_message:
338
329
  rdoc_options: []
339
330
  require_paths:
340
331
  - lib
@@ -342,15 +333,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
342
333
  requirements:
343
334
  - - ">="
344
335
  - !ruby/object:Gem::Version
345
- version: '2.4'
336
+ version: '2.5'
346
337
  required_rubygems_version: !ruby/object:Gem::Requirement
347
338
  requirements:
348
- - - ">="
339
+ - - ">"
349
340
  - !ruby/object:Gem::Version
350
- version: '0'
341
+ version: 1.3.1
351
342
  requirements: []
352
- rubygems_version: 3.1.2
353
- signing_key:
343
+ rubygems_version: 3.2.15
344
+ signing_key:
354
345
  specification_version: 4
355
346
  summary: Minimal Ruby library for Appium.
356
347
  test_files: []
@@ -1,91 +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
- def status
46
- execute :status
47
- end
48
-
49
- # For Appium
50
- def log_event(vendor, event)
51
- execute :post_log_event, {}, { vendor: vendor, event: event }
52
- end
53
-
54
- # For Appium
55
- def log_events(type = nil)
56
- args = {}
57
- args['type'] = type unless type.nil?
58
-
59
- execute :get_log_events, {}, args
60
- end
61
-
62
- def take_element_screenshot(element)
63
- execute :take_element_screenshot, id: element.ref
64
- end
65
-
66
- def take_viewport_screenshot
67
- # TODO: this hasn't been supported by Espresso driver
68
- execute_script('mobile: viewportScreenshot')
69
- end
70
-
71
- def send_actions(_data)
72
- raise Error::UnsupportedOperationError, '#send_actions has not been supported in MJSONWP'
73
- end
74
-
75
- # For Appium
76
- # @param [Hash] id The id which can get as a response from server
77
- # @return [::Selenium::WebDriver::Element]
78
- def convert_to_element(id)
79
- ::Selenium::WebDriver::Element.new self, element_id_from(id)
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
87
- end # class MJSONWP
88
- end # class Bridge
89
- end # class Base
90
- end # module Core
91
- end # module Appium
@@ -1,248 +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 W3C < ::Selenium::WebDriver::Remote::W3C::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
- include Device::Orientation
36
-
37
- def commands(command)
38
- ::Appium::Core::Commands::W3C::COMMANDS[command]
39
- end
40
-
41
- # Returns all available sessions on the Appium server instance
42
- def sessions
43
- execute :get_all_sessions
44
- end
45
-
46
- def status
47
- execute :status
48
- end
49
-
50
- # Perform touch actions for W3C module.
51
- # Generate +touch+ pointer action here and users can use this via +driver.action+
52
- # - https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/W3CActionBuilder.html
53
- # - https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/PointerActions.html
54
- # - https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/KeyActions.html
55
- #
56
- # 'mouse' action is by default in the Ruby client. Appium server force the +mouse+ action to +touch+ once in
57
- # the server side. So we don't consider the case.
58
- #
59
- # @example
60
- #
61
- # element = @driver.find_element(:id, "some id")
62
- # @driver.action.click(element).perform # The 'click' is a part of 'PointerActions'
63
- #
64
- def action(async = false)
65
- # Used for default duration of each touch actions
66
- # Override from 250 milliseconds to 50 milliseconds
67
- action_builder = super
68
- action_builder.default_move_duration = 0.05
69
- action_builder
70
- end
71
-
72
- # Port from MJSONWP
73
- def get_timeouts
74
- execute :get_timeouts
75
- end
76
-
77
- # Port from MJSONWP
78
- def session_capabilities
79
- ::Selenium::WebDriver::Remote::W3C::Capabilities.json_create execute(:get_capabilities)
80
- end
81
-
82
- # Port from MJSONWP
83
- def send_keys_to_active_element(key)
84
- text = ::Selenium::WebDriver::Keys.encode(key).join('')
85
- execute :send_keys_to_active_element, {}, { value: text.split(//) }
86
- end
87
-
88
- # For Appium
89
- # override
90
- def page_source
91
- # For W3C
92
- # execute_script('var source = document.documentElement.outerHTML;' \
93
- # 'if (!source) { source = new XMLSerializer().serializeToString(document); }' \
94
- # 'return source;')
95
- execute :get_page_source
96
- end
97
-
98
- # For Appium
99
- # override
100
- def element_displayed?(element)
101
- # For W3C
102
- # https://github.com/SeleniumHQ/selenium/commit/b618499adcc3a9f667590652c5757c0caa703289
103
- # execute_atom :isDisplayed, element
104
- execute :is_element_displayed, id: element.ref
105
- end
106
-
107
- # For Appium
108
- # override
109
- def element_attribute(element, name)
110
- # For W3C in Selenium Client
111
- # execute_atom :getAttribute, element, name
112
- execute :get_element_attribute, id: element.ref, name: name
113
- end
114
-
115
- # For Appium
116
- # override
117
- def find_element_by(how, what, parent = nil)
118
- how, what = convert_locators(how, what)
119
-
120
- id = if parent
121
- execute :find_child_element, { id: parent }, { using: how, value: what }
122
- else
123
- execute :find_element, {}, { using: how, value: what }
124
- end
125
- ::Selenium::WebDriver::Element.new self, element_id_from(id)
126
- end
127
-
128
- # For Appium
129
- # override
130
- def find_elements_by(how, what, parent = nil)
131
- how, what = convert_locators(how, what)
132
-
133
- ids = if parent
134
- execute :find_child_elements, { id: parent }, { using: how, value: what }
135
- else
136
- execute :find_elements, {}, { using: how, value: what }
137
- end
138
-
139
- ids.map { |id| ::Selenium::WebDriver::Element.new self, element_id_from(id) }
140
- end
141
-
142
- # For Appium
143
- # @param [Hash] id The id which can get as a response from server
144
- # @return [::Selenium::WebDriver::Element]
145
- def convert_to_element(id)
146
- ::Selenium::WebDriver::Element.new self, element_id_from(id)
147
- end
148
-
149
- # For Appium
150
- # override
151
- # called in 'extend DriverExtensions::HasNetworkConnection'
152
- def network_connection
153
- execute :get_network_connection
154
- end
155
-
156
- # For Appium
157
- # override
158
- # called in 'extend DriverExtensions::HasNetworkConnection'
159
- def network_connection=(type)
160
- execute :set_network_connection, {}, { parameters: { type: type } }
161
- end
162
-
163
- # For Appium
164
- # No implementation for W3C webdriver module
165
- # called in 'extend DriverExtensions::HasLocation'
166
- def location
167
- obj = execute(:get_location) || {}
168
- ::Selenium::WebDriver::Location.new obj['latitude'], obj['longitude'], obj['altitude']
169
- end
170
-
171
- # For Appium
172
- # No implementation for W3C webdriver module
173
- def set_location(lat, lon, alt = 0.0, speed: nil)
174
- loc = { latitude: lat, longitude: lon, altitude: alt }
175
- loc[:speed] = speed unless speed.nil?
176
- execute :set_location, {}, { location: loc }
177
- end
178
-
179
- #
180
- # logs
181
- #
182
- # For Appium
183
- # No implementation for W3C webdriver module
184
- def available_log_types
185
- types = execute :get_available_log_types
186
- Array(types).map(&:to_sym)
187
- end
188
-
189
- # For Appium
190
- # No implementation for W3C webdriver module
191
- def log(type)
192
- data = execute :get_log, {}, { type: type.to_s }
193
-
194
- Array(data).map do |l|
195
- begin
196
- ::Selenium::WebDriver::LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
197
- rescue KeyError
198
- next
199
- end
200
- end
201
- end
202
-
203
- # For Appium
204
- def log_event(vendor, event)
205
- execute :post_log_event, {}, { vendor: vendor, event: event }
206
- end
207
-
208
- # For Appium
209
- def log_events(type = nil)
210
- args = {}
211
- args['type'] = type unless type.nil?
212
-
213
- execute :get_log_events, {}, args
214
- end
215
-
216
- def take_viewport_screenshot
217
- execute_script('mobile: viewportScreenshot')
218
- end
219
-
220
- def take_element_screenshot(element)
221
- execute :take_element_screenshot, id: element.ref
222
- end
223
-
224
- private
225
-
226
- # Don't convert locators for Appium Client
227
- # TODO: Only for Appium. Ideally, we'd like to keep the selenium-webdriver
228
- def convert_locators(how, what)
229
- # case how
230
- # when 'class name'
231
- # how = 'css selector'
232
- # what = ".#{escape_css(what)}"
233
- # when 'id'
234
- # how = 'css selector'
235
- # what = "##{escape_css(what)}"
236
- # when 'name'
237
- # how = 'css selector'
238
- # what = "*[name='#{escape_css(what)}']"
239
- # when 'tag name'
240
- # how = 'css selector'
241
- # end
242
- [how, what]
243
- end
244
- end # class W3C
245
- end # class Bridge
246
- end # class Base
247
- end # module Core
248
- end # module Appium