appium_lib_core 6.2.1 → 6.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d75095d146ec0e3786352920f8d1fe385cedab5c8faddc6292db1cd94cd5e111
4
- data.tar.gz: be514be276344a3b488238716890d3bd99fbc1d9da3317ccb4ee943da8cf9ee3
3
+ metadata.gz: c45a558b448d89b1b356b221257279ff8c148680a1dc09f7414877e6e59a6257
4
+ data.tar.gz: d09d57109c80759c9b92942b7f8e1424c2614f34e4fcdbe9f6d4d0e48ee41816
5
5
  SHA512:
6
- metadata.gz: 40c066943b4d7c7f879a991b40b88d34da0317c0099c9fd14f011de8769d7d5cbc34665183b8f034ac532a7d5e5dd616aba4d433d4731fd37a9992ad82384108
7
- data.tar.gz: a277b62b251f4557592bbccc79816fe75d833b324965d121225d39364bfa2d5f0b2e62eff41eafc7a11996564046775dd5da9c0c4e0b85ca0248b8e3ba9ae845
6
+ metadata.gz: 6f50481e6656b18e7dfe5dc631137ab1ab041c9c6087fcf27b1fd24e91814e83ce051f22db1a3e4b41f5d2a4b8320e2ac7c323638e9e9b76d2508d66a7992cdf
7
+ data.tar.gz: 0b04644ee8c7704080935777b01886cca17acce8dab8c7953b769c9dd9ca33efc588e3da5e08bba6a91f0ac17bde973c607f3b886c4724eb84be3c44aece2690
data/CHANGELOG.md CHANGED
@@ -10,6 +10,12 @@ Read `release_notes.md` for commit level details.
10
10
 
11
11
  ### Deprecations
12
12
 
13
+ ## [6.3.0] - 2023-03-14
14
+
15
+ ### Enhancements
16
+ - Support custom listener
17
+ - e.g. A listener named `CustomListener` which inherits `::Selenium::WebDriver::Support::AbstractEventListener` can set as `appium_lib: { listener: CustomListener.new}` capability
18
+
13
19
  ## [6.2.1] - 2023-03-09
14
20
 
15
21
  ### Enhancements
data/README.md CHANGED
@@ -154,6 +154,29 @@ attached_driver.page_source
154
154
  Read [Appium/Core/Driver](https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Driver) to catch up with available capabilities.
155
155
  Capabilities affect only ruby_lib is [Appium/Core/Options](https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Options).
156
156
 
157
+
158
+ ### Gives custom listener
159
+
160
+ An example to define a customer listener with [Selenium::WebDriver::Support::AbstractEventListener](https://www.selenium.dev/selenium/docs/api/rb/Selenium/WebDriver/Support/AbstractEventListener.html)
161
+
162
+ ```ruby
163
+ class CustomListener < ::Selenium::WebDriver::Support::AbstractEventListener
164
+ // something
165
+ end
166
+ capabilities: {
167
+ platformName: :ios,
168
+ platformVersion: '11.0',
169
+ deviceName: 'iPhone Simulator',
170
+ automationName: 'XCUITest',
171
+ app: '/path/to/MyiOS.app'
172
+ },
173
+ appium_lib: {
174
+ listener: CustomListener.new
175
+ }
176
+ @core = Appium::Core.for capabilities: capabilities, appium_lib: appium_lib
177
+ @core.start_driver
178
+ ```
179
+
157
180
  # Development
158
181
  - Demo app
159
182
  - https://android.googlesource.com/platform/development/+/master/samples/ApiDemos
@@ -44,16 +44,25 @@ module Appium
44
44
  # Do not use this for general use. Used by flutter driver to get bridge for creating a new element
45
45
  attr_reader :bridge
46
46
 
47
- private
48
-
49
47
  def initialize(bridge: nil, listener: nil, **opts)
48
+ original_opts = opts.dup
49
+
50
50
  # For ::Appium::Core::Waitable
51
51
  @wait_timeout = opts.delete(:wait_timeout)
52
52
  @wait_interval = opts.delete(:wait_interval)
53
53
 
54
- super
54
+ # Selenium WebDriver attributes
55
+ @devtools = nil
56
+ @bidi = nil
57
+
58
+ # in the selenium webdriver as well
59
+ bridge ||= create_bridge(**opts)
60
+ add_extensions(bridge.browser)
61
+ @bridge = listener ? ::Appium::Support::EventFiringBridge.new(bridge, listener, **original_opts) : bridge
55
62
  end
56
63
 
64
+ private
65
+
57
66
  # Create a proper bridge instance.
58
67
  #
59
68
  # @return [::Appium::Core::Base::Bridge]
@@ -1069,7 +1078,7 @@ module Appium
1069
1078
  #
1070
1079
  # @param [String] img_path A path to a partial image you'd like to find
1071
1080
  #
1072
- # @return [Array<Selenium::WebDriver::Element>]
1081
+ # @return [Array<::Appium::Core::Element>]
1073
1082
  #
1074
1083
  # @example
1075
1084
  #
@@ -276,6 +276,23 @@ module Appium
276
276
  # @core = Appium::Core.for(opts) # create a core driver with 'opts' and extend methods into 'self'
277
277
  # @core.start_driver # start driver with 'url'. Connect to 'http://custom-host:8080/wd/hub.com'
278
278
  #
279
+ # # With a custom listener
280
+ # class CustomListener < ::Selenium::WebDriver::Support::AbstractEventListener
281
+ # // something
282
+ # end
283
+ # capabilities: {
284
+ # platformName: :ios,
285
+ # platformVersion: '11.0',
286
+ # deviceName: 'iPhone Simulator',
287
+ # automationName: 'XCUITest',
288
+ # app: '/path/to/MyiOS.app'
289
+ # },
290
+ # appium_lib: {
291
+ # listener: CustomListener.new,
292
+ # }
293
+ # @core = Appium::Core.for capabilities: capabilities, appium_lib: appium_lib
294
+ # @core.start_driver
295
+ #
279
296
  def self.for(opts = {})
280
297
  new.setup_for_new_session(opts)
281
298
  end
@@ -0,0 +1,57 @@
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 Support
17
+ class EventFiringBridge < ::Selenium::WebDriver::Support::EventFiringBridge
18
+ # This module inherits ::Selenium::WebDriver::Support::EventFiringBridge
19
+ # to provide customer listener availability.
20
+ # https://github.com/SeleniumHQ/selenium/blob/trunk/rb/lib/selenium/webdriver/support/event_firing_bridge.rb#L79
21
+
22
+ def initialize(delegate, listener, **opts)
23
+ @appium_options = opts
24
+ super delegate, listener
25
+ end
26
+
27
+ def find_element_by(how, what, parent = nil)
28
+ e = dispatch(:find, how, what, driver) do
29
+ @delegate.find_element_by how, what, parent
30
+ end
31
+
32
+ ::Appium::Core::Element.new self, e.ref.last
33
+ end
34
+
35
+ def find_elements_by(how, what, parent = nil)
36
+ es = dispatch(:find, how, what, driver) do
37
+ @delegate.find_elements_by(how, what, parent)
38
+ end
39
+
40
+ es.map { |e| ::Appium::Core::Element.new self, e.ref.last }
41
+ end
42
+
43
+ private
44
+
45
+ def create_element(ref)
46
+ ::Appium::Core::Element.new @delegate, ref
47
+ end
48
+
49
+ def driver
50
+ # To not gives the listener
51
+ @appium_options.delete(:listener)
52
+
53
+ @driver ||= ::Appium::Core::Base::Driver.new(bridge: self, listener: nil, **@appium_options)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -14,7 +14,7 @@
14
14
 
15
15
  module Appium
16
16
  module Core
17
- VERSION = '6.2.1' unless defined? ::Appium::Core::VERSION
18
- DATE = '2023-03-09' unless defined? ::Appium::Core::DATE
17
+ VERSION = '6.3.0' unless defined? ::Appium::Core::VERSION
18
+ DATE = '2023-03-14' unless defined? ::Appium::Core::DATE
19
19
  end
20
20
  end
@@ -19,6 +19,7 @@ require_relative 'appium_lib_core/common'
19
19
  require_relative 'appium_lib_core/driver'
20
20
  require_relative 'appium_lib_core/device'
21
21
  require_relative 'appium_lib_core/element'
22
+ require_relative 'appium_lib_core/support/event_firing_bridge'
22
23
 
23
24
  module Appium
24
25
  # @private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_lib_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.1
4
+ version: 6.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuaki MATSUO
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-09 00:00:00.000000000 Z
11
+ date: 2023-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -259,6 +259,7 @@ files:
259
259
  - lib/appium_lib_core/mac2/bridge.rb
260
260
  - lib/appium_lib_core/mac2/device.rb
261
261
  - lib/appium_lib_core/mac2/device/screen.rb
262
+ - lib/appium_lib_core/support/event_firing_bridge.rb
262
263
  - lib/appium_lib_core/version.rb
263
264
  - lib/appium_lib_core/windows.rb
264
265
  - lib/appium_lib_core/windows/bridge.rb