diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index c662bc99..b3a3f1a9 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -30,6 +30,7 @@ jobs: - name: Run tests run: | bundle exec rake rubocop + bundle exec rake steep bundle exec rake test:unit APPIUM_DRIVER=espresso bundle exec rake test:unit:android APPIUM_DRIVER=appium bundle exec rake test:unit diff --git a/Gemfile b/Gemfile index d8bb84da..b2b1ab97 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,6 @@ gem 'parallel_tests' gem 'rake', '~> 13.0' gem 'rubocop', '1.81.7' gem 'simplecov' -gem 'steep', '~> 1.9.3' +gem 'steep', '~> 1.10.0' gem 'webmock', '~> 3.26.0' gem 'yard', '~> 0.9.11' diff --git a/Rakefile b/Rakefile index 1b0d2f0e..6e22bc9e 100644 --- a/Rakefile +++ b/Rakefile @@ -120,5 +120,5 @@ end desc('Run Steep type check') task :steep do - system('steep check') + system 'steep check --severity-level=error' end diff --git a/lib/appium_lib_core.rb b/lib/appium_lib_core.rb index 1c65e082..77e8ce27 100644 --- a/lib/appium_lib_core.rb +++ b/lib/appium_lib_core.rb @@ -61,8 +61,8 @@ def self.symbolize_keys(hash, nested: false, enable_deprecation_msg: true) module Core # @see Appium::Core::Driver.for - def self.for(*args) - Core::Driver.for(*args) + def self.for(opts = {}) + Core::Driver.for(opts) end end end diff --git a/lib/appium_lib_core/common/base/bidi_bridge.rb b/lib/appium_lib_core/common/base/bidi_bridge.rb index 349805b9..566fe0cc 100644 --- a/lib/appium_lib_core/common/base/bidi_bridge.rb +++ b/lib/appium_lib_core/common/base/bidi_bridge.rb @@ -18,6 +18,8 @@ module Appium module Core class Base class BiDiBridge < ::Appium::Core::Base::Bridge + # steep:ignore:start + attr_reader :bidi # Override @@ -85,6 +87,8 @@ def close execute(:close_window).tap { |handles| bidi.close if handles.empty? } end + # steep:ignore:end + private def browsing_context diff --git a/lib/appium_lib_core/common/base/bridge.rb b/lib/appium_lib_core/common/base/bridge.rb index 18c04d1d..2d5b051d 100644 --- a/lib/appium_lib_core/common/base/bridge.rb +++ b/lib/appium_lib_core/common/base/bridge.rb @@ -37,7 +37,9 @@ class Bridge < ::Selenium::WebDriver::Remote::Bridge include Device::ExecuteDriver include Device::Orientation + # steep:ignore:start Bridge.locator_converter = LocatorConverter.new + # steep:ignore:end # Prefix for extra capability defined by W3C APPIUM_PREFIX = 'appium:' @@ -141,7 +143,7 @@ def add_appium_prefix(capabilities) private def camel_case(str_or_sym) - str_or_sym.to_s.gsub(/_([a-z])/) { Regexp.last_match(1).upcase } + str_or_sym.to_s.gsub(/_([a-z])/) { Regexp.last_match(1)&.upcase } end def extension_prefix?(capability_name) @@ -204,12 +206,14 @@ def status # @driver.action.click(element).perform # The 'click' is a part of 'PointerActions' # def action(_deprecated_async = nil, async: false, devices: nil) + # steep:ignore:start ::Selenium::WebDriver::ActionBuilder.new( self, devices: devices || [::Selenium::WebDriver::Interactions.pointer(:touch, name: 'touch')], async: async, duration: 50 # milliseconds ) + # steep:ignore:end end # Port from MJSONWP @@ -278,7 +282,9 @@ def log(type) data = execute :get_log, {}, { type: type.to_s } Array(data).map do |l| + # steep:ignore:start ::Selenium::WebDriver::LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message') + # steep:ignore:end rescue KeyError next end diff --git a/lib/appium_lib_core/common/base/driver.rb b/lib/appium_lib_core/common/base/driver.rb index 27098e22..00239af8 100644 --- a/lib/appium_lib_core/common/base/driver.rb +++ b/lib/appium_lib_core/common/base/driver.rb @@ -36,7 +36,9 @@ class Driver < ::Selenium::WebDriver::Driver include ::Appium::Core::Waitable + # steep:ignore:start ::Selenium::WebDriver::SearchContext.extra_finders = ::Appium::Core::Base::SearchContext::APPIUM_EXTRA_FINDERS + # steep:ignore:end # Private API. # Do not use this for general use. Used by flutter driver to get bridge for creating a new element @@ -57,7 +59,9 @@ def initialize(bridge: nil, listener: nil, **opts) # rubocop:disable Lint/Missin # internal use @has_bidi = false + # steep:ignore:start ::Selenium::WebDriver::Remote::Bridge.element_class = ::Appium::Core::Element + # steep:ignore:end bridge ||= create_bridge(**opts) add_extensions(bridge.browser) @bridge = listener ? ::Appium::Support::EventFiringBridge.new(bridge, listener, **original_opts) : bridge @@ -83,7 +87,9 @@ def create_bridge(**opts) @has_bidi = capabilities && capabilities['webSocketUrl'] ? true : false bridge_clzz = @has_bidi ? ::Appium::Core::Base::BiDiBridge : ::Appium::Core::Base::Bridge + # steep:ignore:start bridge = bridge_clzz.new(**bridge_opts) + # steep:ignore:end if session_id.nil? bridge.create_session(capabilities) @@ -220,7 +226,9 @@ def add_command(method:, url:, name:, &block) def key_action(async: false) @bridge.action( async: async, + # steep:ignore:start devices: [::Selenium::WebDriver::Interactions.key('keyboard')] + # steep:ignore:end ) end @@ -627,7 +635,7 @@ def background_app(duration = 0) # def install_app(path, **options) # TODO: use mobile command in the background? - options = options.transform_keys { |key| key.to_s.gsub(/_./) { |v| v[1].upcase } } unless options.nil? + options = options.transform_keys { |key| key.to_s.gsub(/_./) { |v| v[1]&.upcase } } unless options.nil? @bridge.install_app(path, options) end diff --git a/lib/appium_lib_core/common/wait.rb b/lib/appium_lib_core/common/wait.rb index ea3bc755..ce252b49 100644 --- a/lib/appium_lib_core/common/wait.rb +++ b/lib/appium_lib_core/common/wait.rb @@ -62,7 +62,9 @@ def until(timeout: DEFAULT_TIMEOUT, interval: DEFAULT_INTERVAL, message: nil, ig end msg = message_for timeout, message + # steep:ignore:start msg += " (#{last_error.message})" if last_error + # steep:ignore:end raise TimeoutError, msg end @@ -109,7 +111,9 @@ def until_true(timeout: DEFAULT_TIMEOUT, interval: DEFAULT_INTERVAL, message: ni end msg = message_for timeout, message + # steep:ignore:start msg += " (#{last_error.message})" if last_error + # steep:ignore:end raise TimeoutError, msg end diff --git a/lib/appium_lib_core/common/ws/websocket.rb b/lib/appium_lib_core/common/ws/websocket.rb index 883e65ca..d7b43d0a 100644 --- a/lib/appium_lib_core/common/ws/websocket.rb +++ b/lib/appium_lib_core/common/ws/websocket.rb @@ -43,6 +43,7 @@ def initialize(url:, protocols: nil, options: {}) @endpoint = url @ws_thread = Thread.new do + # steep:ignore:start EM.run do @client ||= ::Faye::WebSocket::Client.new(url, protocols, options) @@ -62,6 +63,7 @@ def initialize(url:, protocols: nil, options: {}) handle_close(close.code, close.reason) end end + # steep:ignore:end end end @@ -120,7 +122,7 @@ def close(code: nil, reason: 'close from ruby_lib_core') # Default is just put a debug message. # def handle_open - ::Appium::Logger.debug %W(#{self.class} :open) + ::Appium::Logger.debug("#{self.class} :open") end # Standard out by default @@ -134,7 +136,7 @@ def handle_open # In general, users should override this handler to handle messages from the peer. # def handle_message_data(data) - ::Appium::Logger.debug %W(#{self.class} :message #{data}) + ::Appium::Logger.debug("#{self.class} :message #{data}") $stdout << "#{data}\n" end @@ -145,7 +147,7 @@ def handle_message_data(data) # Default is just put a error message. # def handle_error - ::Appium::Logger.error %W(#{self.class} :error) + ::Appium::Logger.error("#{self.class} :error") end # @@ -156,9 +158,11 @@ def handle_error # The methods also clear +client+ instance and stop the eventmachine which is called in initialising this class. # def handle_close(code, reason) - ::Appium::Logger.debug %W(#{self.class} :close #{code} #{reason}) + ::Appium::Logger.debug("#{self.class} :close #{code} #{reason}") @client = nil + # steep:ignore:start EM.stop + # steep:ignore:end end end # module WebSocket end # module Core diff --git a/lib/appium_lib_core/driver.rb b/lib/appium_lib_core/driver.rb index 634a2a0e..71842bee 100644 --- a/lib/appium_lib_core/driver.rb +++ b/lib/appium_lib_core/driver.rb @@ -602,12 +602,19 @@ def extend_for(device:, automation_name:) # rubocop:disable Metrics/CyclomaticCo # @private def get_caps(opts) - Core::Base::Capabilities.new(opts[:caps] || opts[:capabilities] || {}) + o = opts || {} + + raw_caps = o[:caps] || o[:capabilities] + caps_hash = raw_caps.is_a?(Hash) ? raw_caps : {} + + Core::Base::Capabilities.new(caps_hash) end - # @private def get_appium_lib_opts(opts) - opts[:appium_lib] || {} + o = opts || {} + + val = o[:appium_lib] + val.is_a?(Hash) ? val : {} end # @private @@ -621,17 +628,21 @@ def get_app # Use @caps[:app] without modifications if the path isn't HTTP/S or local path. def set_app_path # FIXME: maybe `:app` should check `app` as well. - return unless @caps && get_app && !get_app.empty? + return unless @caps + + app = get_app # for steep reason + return unless app && app.empty? uri_regex = defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::DEFAULT_PARSER - return if get_app =~ uri_regex.make_regexp + return if app =~ uri_regex.make_regexp - app_path = File.expand_path(get_app) + # steep:ignore + app_path = File.expand_path(app) @caps['app'] = if File.exist? app_path app_path else - ::Appium::Logger.warn("Use #{get_app} directly since #{app_path} does not exist.") - get_app + ::Appium::Logger.warn("Use #{app} directly since #{app_path} does not exist.") + app end end @@ -659,7 +670,7 @@ def set_appium_lib_specific_values(appium_lib_opts) def set_appium_device # https://code.google.com/p/selenium/source/browse/spec-draft.md?repo=mobile @device = get_cap 'platformName' - return @device unless @device + return unless @device @device = convert_to_symbol(convert_downcase(@device)) end diff --git a/lib/appium_lib_core/element.rb b/lib/appium_lib_core/element.rb index 9b7c2b65..2fefb228 100644 --- a/lib/appium_lib_core/element.rb +++ b/lib/appium_lib_core/element.rb @@ -19,7 +19,9 @@ module Core class Element < ::Selenium::WebDriver::Element include ::Appium::Core::Base::TakesScreenshot + # steep:ignore:start ::Selenium::WebDriver::SearchContext.extra_finders = ::Appium::Core::Base::SearchContext::APPIUM_EXTRA_FINDERS + # steep:ignore:end # Retuns the element id. # @@ -58,16 +60,18 @@ def method_missing(method_name, *args, &block) respond_to?(method_name) ? attribute(method_name.to_s.tr('_', '-')) : super end - def respond_to_missing?(*) + def respond_to_missing?(_method_name, _include_private = false) true end # Alias for type alias type send_keys + # @deprecated Please use `Element#rect` instead to get location information. + # # For use with location_rel. # - # @return [::Selenium::WebDriver::Point] the relative x, y in a struct. ex: { x: 0.50, y: 0.20 } + # @return [Struct(:x, :y)] the relative x, y in a struct in string. # # @example # @@ -86,7 +90,8 @@ def location_rel(driver) center_y = location_y + (size_height / 2.0) w = driver.window_size - ::Selenium::WebDriver::Point.new "#{center_x} / #{w.width.to_f}", "#{center_y} / #{w.height.to_f}" + point = Struct.new(:x, :y) + point.new("#{center_x} / #{w.width.to_f}", "#{center_y} / #{w.height.to_f}") end # Return an element screenshot as base64 diff --git a/rbs_collection.lock.yaml b/rbs_collection.lock.yaml index e4fe5449..0beabd27 100644 --- a/rbs_collection.lock.yaml +++ b/rbs_collection.lock.yaml @@ -6,7 +6,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: addressable @@ -14,7 +14,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: ast @@ -22,23 +22,27 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: base64 - version: '0' + version: 0.3.0 source: - type: stdlib + type: rubygems - name: bigdecimal - version: '0' + version: '3.1' source: - type: stdlib + type: git + name: ruby/gem_rbs_collection + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems - name: concurrent-ruby version: '1.1' source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: connection_pool @@ -46,14 +50,22 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: csv + version: '3.3' + source: + type: git + name: ruby/gem_rbs_collection + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +- name: date version: '0' source: type: stdlib -- name: date +- name: digest version: '0' source: type: stdlib @@ -62,7 +74,7 @@ gems: source: type: stdlib - name: ffi - version: 1.17.0 + version: 1.17.2 source: type: rubygems - name: fileutils @@ -78,7 +90,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: i18n @@ -86,7 +98,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: json @@ -98,7 +110,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: logger @@ -106,14 +118,18 @@ gems: source: type: stdlib - name: minitest - version: '0' + version: '5.25' source: - type: stdlib + type: git + name: ruby/gem_rbs_collection + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems - name: monitor version: '0' source: type: stdlib -- name: mutex_m +- name: openssl version: '0' source: type: stdlib @@ -126,7 +142,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: parser @@ -134,15 +150,19 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems +- name: prism + version: 1.6.0 + source: + type: rubygems - name: rainbow version: '3.0' source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: rake @@ -150,7 +170,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: regexp_parser @@ -158,7 +178,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: ripper @@ -170,15 +190,15 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: rubocop-ast - version: '1.30' + version: '1.46' source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: rubyzip @@ -186,7 +206,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: securerandom @@ -198,13 +218,21 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: singleton version: '0' source: type: stdlib +- name: socket + version: '0' + source: + type: stdlib +- name: stringio + version: '0' + source: + type: stdlib - name: strscan version: '0' source: @@ -214,7 +242,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: time @@ -230,15 +258,19 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems +- name: uri + version: '0' + source: + type: stdlib - name: webmock version: '3.19' source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: yard @@ -246,7 +278,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 3670834268f4ea9c10aefeffae7e072b51256375 + revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems gemfile_lock_path: Gemfile.lock diff --git a/sig/gems/forwardable.rbs b/sig/gems/forwardable.rbs new file mode 100644 index 00000000..980b2b22 --- /dev/null +++ b/sig/gems/forwardable.rbs @@ -0,0 +1,17 @@ +# The Forwardable module provides delegation of specified methods to a designated object +module Forwardable + # Defines delegators for instance methods + def def_instance_delegators: (Symbol | String accessor, *Symbol methods) -> void + + def def_instance_delegator: (Symbol | String accessor, Symbol method, ?Symbol ali) -> void + + # Defines delegators for singleton methods (used with extend Forwardable) + def def_single_delegators: (Symbol | String accessor, *Symbol methods) -> void + + def def_single_delegator: (Symbol | String accessor, Symbol method, ?Symbol ali) -> void + + # Common aliases that work in both instance and singleton contexts + def def_delegators: (Symbol | String accessor, *Symbol methods) -> void + + def def_delegator: (Symbol | String accessor, Symbol method, ?Symbol ali) -> void +end diff --git a/sig/gems/selenium/atoms.rbs b/sig/gems/selenium/atoms.rbs index e825969f..5ff85588 100644 --- a/sig/gems/selenium/atoms.rbs +++ b/sig/gems/selenium/atoms.rbs @@ -2,7 +2,6 @@ module Selenium module WebDriver module Atoms include _Bridge - include _ExecuteScript def atom_script: (Symbol) -> String diff --git a/sig/gems/selenium/bidi/browsing_context.rbs b/sig/gems/selenium/bidi/browsing_context.rbs index a690a382..243d2d22 100644 --- a/sig/gems/selenium/bidi/browsing_context.rbs +++ b/sig/gems/selenium/bidi/browsing_context.rbs @@ -10,7 +10,7 @@ module Selenium READINESS_STATE: Hash[Symbol, String] - def initialize: (driver: untyped, ?browsing_context_id: untyped?, ?type: untyped?, ?reference_context: untyped?) -> void + def initialize: (untyped bridge) -> void def navigate: (url: untyped, ?readiness_state: untyped?) -> untyped diff --git a/sig/gems/selenium/bridge.rbs b/sig/gems/selenium/bridge.rbs index 4e06cbd6..4f2843e7 100644 --- a/sig/gems/selenium/bridge.rbs +++ b/sig/gems/selenium/bridge.rbs @@ -269,6 +269,9 @@ module Selenium UNICODE_CODE_POINT: 30 def escape_css: (untyped string) -> untyped + + def self.extra_commands: () -> Hash[Symbol, Array[untyped]] + def self.add_command: (Symbol name, Symbol method, String url, ?untyped block) -> void end end end diff --git a/sig/gems/selenium/chromium/features.rbs b/sig/gems/selenium/chromium/features.rbs index a48cca64..ef1f5c49 100644 --- a/sig/gems/selenium/chromium/features.rbs +++ b/sig/gems/selenium/chromium/features.rbs @@ -35,7 +35,7 @@ module Selenium def available_log_types: () -> Array[Symbol] def log: (Symbol type) -> Array[Hash[String, untyped]] | - (Symbol type) -> Array[LogEntry] + (Symbol type) -> Array[Selenium::WebDriver::LogEntry] end end end diff --git a/sig/gems/selenium/common/element.rbs b/sig/gems/selenium/common/element.rbs index c534b1e0..d8b51c14 100644 --- a/sig/gems/selenium/common/element.rbs +++ b/sig/gems/selenium/common/element.rbs @@ -47,6 +47,8 @@ module Selenium alias [] attribute + def rect: () -> untyped + def ref: () -> ::Array[:element | untyped] def to_json: () -> untyped diff --git a/sig/gems/selenium/driver.rbs b/sig/gems/selenium/driver.rbs index 45bbded7..b83debf6 100644 --- a/sig/gems/selenium/driver.rbs +++ b/sig/gems/selenium/driver.rbs @@ -2,6 +2,16 @@ module Selenium module WebDriver class Driver def capabilities: () -> untyped + + def manage: () -> untyped + + def navigate: () -> untyped + + def find_element: (untyped how, ?untyped? what) -> untyped + + def find_elements: (untyped how, ?untyped? what) -> untyped + + def add_extensions: (untyped mod) -> untyped end end end diff --git a/sig/gems/selenium/fedcm.rbs b/sig/gems/selenium/fedcm.rbs new file mode 100644 index 00000000..c32a3dc4 --- /dev/null +++ b/sig/gems/selenium/fedcm.rbs @@ -0,0 +1,12 @@ +module FedCM + class Account + # Keep fields loose to avoid downstream mismatches. + attr_reader id: untyped + attr_reader email: untyped + attr_reader name: untyped + attr_reader given_name: untyped + attr_reader picture_url: untyped + + def initialize: (*untyped) -> void + end +end \ No newline at end of file diff --git a/sig/gems/selenium/firefox/profile.rbs b/sig/gems/selenium/firefox/profile.rbs index 58b93624..c0c5719f 100644 --- a/sig/gems/selenium/firefox/profile.rbs +++ b/sig/gems/selenium/firefox/profile.rbs @@ -50,8 +50,6 @@ module Selenium def proxy=: (untyped proxy) -> untyped - alias as_json encoded - private def set_manual_proxy_preference: (untyped key, untyped value) -> untyped? diff --git a/sig/gems/selenium/log_entry.rbs b/sig/gems/selenium/log_entry.rbs new file mode 100644 index 00000000..db4b85a0 --- /dev/null +++ b/sig/gems/selenium/log_entry.rbs @@ -0,0 +1,12 @@ +module Selenium + module WebDriver + class LogEntry + # Keep attributes loose to avoid downstream mismatches; refine later if desired. + attr_reader level: untyped + attr_reader message: String + attr_reader timestamp: Integer + + def initialize: (untyped level, String message, Integer timestamp) -> void + end + end +end diff --git a/sig/gems/selenium/remote/capabilities.rbs b/sig/gems/selenium/remote/capabilities.rbs index b5dc63fa..794e7c2f 100644 --- a/sig/gems/selenium/remote/capabilities.rbs +++ b/sig/gems/selenium/remote/capabilities.rbs @@ -2,6 +2,12 @@ module Selenium module WebDriver module Remote class Capabilities + def initialize: (?Hash[untyped, untyped]) -> void + def []: (untyped key) -> untyped + def []=: (untyped key, untyped value) -> untyped + + # Add this: + def self.json_create: (Hash[untyped, untyped] value) -> Capabilities end end end diff --git a/sig/interfaces/bridge.rbs b/sig/interfaces/bridge.rbs index 8caa4c7b..a8105836 100644 --- a/sig/interfaces/bridge.rbs +++ b/sig/interfaces/bridge.rbs @@ -2,4 +2,8 @@ interface _Bridge def bridge: -> untyped def execute: (untyped command, ?Hash[untyped, untyped] opts, ?untyped? command_hash) -> untyped + + def execute_script: (String script, *untyped args) -> untyped + + def execute_async_script: (String script, *untyped args) -> untyped end diff --git a/sig/lib/appium_lib_core.rbs b/sig/lib/appium_lib_core.rbs index fd15ab49..7e9a4bbe 100644 --- a/sig/lib/appium_lib_core.rbs +++ b/sig/lib/appium_lib_core.rbs @@ -3,6 +3,6 @@ module Appium -> Hash[Symbol, untyped] module Core - def self.for: (*untyped args) -> Driver + def self.for: (Hash[Symbol, untyped] opts) -> Driver end end diff --git a/sig/lib/appium_lib_core/android/device.rbs b/sig/lib/appium_lib_core/android/device.rbs index f63ff529..ce92d1dc 100644 --- a/sig/lib/appium_lib_core/android/device.rbs +++ b/sig/lib/appium_lib_core/android/device.rbs @@ -2,11 +2,29 @@ module Appium module Core module Android module Device - extend Forwardable + include _Bridge - def self.execute: (Symbol command, ?Hash[untyped, untyped], ?Hash[untyped, untyped]) -> untyped + extend Forwardable def self.extended: (untyped _mod) -> (nil | untyped) + + def open_notifications: () -> untyped + + def current_activity: () -> untyped + + def current_package: () -> untyped + + def get_system_bars: () -> untyped + + def system_bars: () -> untyped + + def toggle_location_services: () -> untyped + + def hide_keyboard: () -> untyped + + def background_app: (Integer duration) -> untyped + + def chrome_send_command: (String cmd, Hash[untyped, untyped] params) -> untyped end end end diff --git a/sig/lib/appium_lib_core/android/device/auth_finger_print.rbs b/sig/lib/appium_lib_core/android/device/auth_finger_print.rbs index 757f0d55..7bd03551 100644 --- a/sig/lib/appium_lib_core/android/device/auth_finger_print.rbs +++ b/sig/lib/appium_lib_core/android/device/auth_finger_print.rbs @@ -3,7 +3,7 @@ module Appium module Android module Device module Authentication - def execute: (Symbol command, ?Hash[untyped, untyped], ?Hash[untyped, untyped]) -> untyped + include _Bridge def self.add_methods: () -> untyped end diff --git a/sig/lib/appium_lib_core/android/device/clipboard.rbs b/sig/lib/appium_lib_core/android/device/clipboard.rbs index 76eae50e..b6b1ab20 100644 --- a/sig/lib/appium_lib_core/android/device/clipboard.rbs +++ b/sig/lib/appium_lib_core/android/device/clipboard.rbs @@ -3,7 +3,7 @@ module Appium module Android module Device module Clipboard - def execute: (Symbol command, ?Hash[untyped, untyped], ?Hash[untyped, untyped]) -> untyped + include _Bridge def self.add_methods: () -> untyped end diff --git a/sig/lib/appium_lib_core/android/device/emulator.rbs b/sig/lib/appium_lib_core/android/device/emulator.rbs index 7c8e7b42..2c7732fa 100644 --- a/sig/lib/appium_lib_core/android/device/emulator.rbs +++ b/sig/lib/appium_lib_core/android/device/emulator.rbs @@ -3,6 +3,8 @@ module Appium module Android module Device module Emulator + include _Bridge + GSM_CALL_ACTIONS: ::Array[:call | :accept | :cancel | :hold] GSM_VOICE_STATES: ::Array[:on | :off | :denied | :searching | :roaming | :home | :unregistered] @@ -14,8 +16,6 @@ module Appium POWER_AC_STATE: ::Array[:on | :off] def self.add_methods: () -> untyped - - def execute: (Symbol command, ?Hash[untyped, untyped], ?Hash[untyped, untyped]) -> untyped end end end diff --git a/sig/lib/appium_lib_core/android/device/network.rbs b/sig/lib/appium_lib_core/android/device/network.rbs deleted file mode 100644 index 0918257b..00000000 --- a/sig/lib/appium_lib_core/android/device/network.rbs +++ /dev/null @@ -1,13 +0,0 @@ -module Appium - module Core - module Android - module Device - module Network - def execute: (Symbol command, ?Hash[untyped, untyped], ?Hash[untyped, untyped]) -> untyped - - def self.add_methods: () -> untyped - end - end - end - end -end diff --git a/sig/lib/appium_lib_core/android/device/performance.rbs b/sig/lib/appium_lib_core/android/device/performance.rbs index 20c0e290..2f4949d4 100644 --- a/sig/lib/appium_lib_core/android/device/performance.rbs +++ b/sig/lib/appium_lib_core/android/device/performance.rbs @@ -3,7 +3,7 @@ module Appium module Android module Device module Performance - def execute: (Symbol command, ?Hash[untyped, untyped], ?Hash[untyped, untyped]) -> untyped + include _Bridge def self.add_methods: () -> untyped end diff --git a/sig/lib/appium_lib_core/android/device/screen.rbs b/sig/lib/appium_lib_core/android/device/screen.rbs index 9199fbd1..1b59b146 100644 --- a/sig/lib/appium_lib_core/android/device/screen.rbs +++ b/sig/lib/appium_lib_core/android/device/screen.rbs @@ -3,6 +3,8 @@ module Appium module Android module Device module Screen + include _Bridge + def self.add_methods: () -> untyped end end diff --git a/sig/lib/appium_lib_core/android/uiautomator2/device/battery.rbs b/sig/lib/appium_lib_core/android/uiautomator2/device/battery.rbs index 6a323fb6..c709a5c6 100644 --- a/sig/lib/appium_lib_core/android/uiautomator2/device/battery.rbs +++ b/sig/lib/appium_lib_core/android/uiautomator2/device/battery.rbs @@ -4,6 +4,8 @@ module Appium module Uiautomator2 module Device module Battery + include _Bridge + def self.add_methods: () -> untyped end end diff --git a/sig/lib/appium_lib_core/common/base/bidi_bridge.rbs b/sig/lib/appium_lib_core/common/base/bidi_bridge.rbs index 0a16a16e..4b220166 100644 --- a/sig/lib/appium_lib_core/common/base/bidi_bridge.rbs +++ b/sig/lib/appium_lib_core/common/base/bidi_bridge.rbs @@ -19,6 +19,10 @@ module Appium def quit: () -> untyped def close: () -> untyped + + private + + def browsing_context: () -> ::Selenium::WebDriver::BiDi::BrowsingContext end end end diff --git a/sig/lib/appium_lib_core/common/base/bridge.rbs b/sig/lib/appium_lib_core/common/base/bridge.rbs index 59c86e32..a3e47815 100644 --- a/sig/lib/appium_lib_core/common/base/bridge.rbs +++ b/sig/lib/appium_lib_core/common/base/bridge.rbs @@ -6,6 +6,8 @@ module Appium end class Bridge < ::Selenium::WebDriver::Remote::Bridge + include _Bridge + @browser: untyped @available_commands: untyped diff --git a/sig/lib/appium_lib_core/common/base/capabilities.rbs b/sig/lib/appium_lib_core/common/base/capabilities.rbs index 88a96364..1feb3a6f 100644 --- a/sig/lib/appium_lib_core/common/base/capabilities.rbs +++ b/sig/lib/appium_lib_core/common/base/capabilities.rbs @@ -3,6 +3,9 @@ module Appium class Base class Capabilities < Selenium::WebDriver::Remote::Capabilities def convert_key: (untyped key) -> untyped + + # Inherit json_create from parent, but you can redeclare for clarity: + def self.json_create: (Hash[untyped, untyped] value) -> Capabilities end end end diff --git a/sig/lib/appium_lib_core/common/base/rotable.rbs b/sig/lib/appium_lib_core/common/base/rotable.rbs index b80e7cc1..43e26b02 100644 --- a/sig/lib/appium_lib_core/common/base/rotable.rbs +++ b/sig/lib/appium_lib_core/common/base/rotable.rbs @@ -4,6 +4,9 @@ module Appium module Rotatable ORIENTATIONS: Array[Symbol] + # Expects including class to have bridge accessor + def bridge: () -> untyped + def rotation=: (untyped orientation) -> untyped alias rotate rotation= diff --git a/sig/lib/appium_lib_core/common/base/search_context.rbs b/sig/lib/appium_lib_core/common/base/search_context.rbs index 9e72ef78..0ded1a79 100644 --- a/sig/lib/appium_lib_core/common/base/search_context.rbs +++ b/sig/lib/appium_lib_core/common/base/search_context.rbs @@ -2,7 +2,7 @@ module Appium module Core class Base module SearchContext - APPIUM_EXTRA_FINDERS: { Symbol => String } + APPIUM_EXTRA_FINDERS: ::Hash[Symbol, String] end end end diff --git a/sig/lib/appium_lib_core/common/device/app_state.rbs b/sig/lib/appium_lib_core/common/device/app_state.rbs index f53207cd..611c6e11 100644 --- a/sig/lib/appium_lib_core/common/device/app_state.rbs +++ b/sig/lib/appium_lib_core/common/device/app_state.rbs @@ -3,9 +3,9 @@ module Appium class Base module Device module AppState - STATUS: ::Array[:not_installed | :not_running | :running_in_background_suspended | :running_in_background | :running_in_foreground] + include _Bridge - def execute: (Symbol command, ?Hash[untyped, untyped], ?Hash[untyped, untyped]) -> untyped + STATUS: ::Array[:not_installed | :not_running | :running_in_background_suspended | :running_in_background | :running_in_foreground] def app_state: (untyped app_id) -> untyped end diff --git a/sig/lib/appium_lib_core/common/device/device.rbs b/sig/lib/appium_lib_core/common/device/device.rbs index 1102609e..10bef760 100644 --- a/sig/lib/appium_lib_core/common/device/device.rbs +++ b/sig/lib/appium_lib_core/common/device/device.rbs @@ -3,7 +3,7 @@ module Appium class Base module Device module Device - def execute: (Symbol command, ?Hash[untyped, untyped], ?Hash[untyped, untyped]) -> untyped + include _Bridge def shake: () -> untyped diff --git a/sig/lib/appium_lib_core/common/device/device_lock.rbs b/sig/lib/appium_lib_core/common/device/device_lock.rbs index c12220b6..1299eca8 100644 --- a/sig/lib/appium_lib_core/common/device/device_lock.rbs +++ b/sig/lib/appium_lib_core/common/device/device_lock.rbs @@ -3,13 +3,13 @@ module Appium class Base module Device module DeviceLock + include _Bridge + def lock: (?untyped? duration) -> untyped def device_locked?: () -> untyped def unlock: () -> untyped - - def execute: (Symbol command, ?Hash[untyped, untyped], ?Hash[untyped, untyped]) -> untyped end end end diff --git a/sig/lib/appium_lib_core/common/device/keyboard.rbs b/sig/lib/appium_lib_core/common/device/keyboard.rbs index 52c9ccd5..f6124317 100644 --- a/sig/lib/appium_lib_core/common/device/keyboard.rbs +++ b/sig/lib/appium_lib_core/common/device/keyboard.rbs @@ -3,9 +3,9 @@ module Appium class Base module Device module Keyboard - def execute: (Symbol command, ?Hash[untyped, untyped], ?Hash[untyped, untyped]) -> untyped + include _Bridge - def hide_keyboard: (?untyped? close_key, ?untyped? strategy) -> untyped + def hide_keyboard: (?untyped? close_key) -> untyped def is_keyboard_shown: () -> untyped end diff --git a/sig/lib/appium_lib_core/common/device/keyevent.rbs b/sig/lib/appium_lib_core/common/device/keyevent.rbs index 494ca13e..276695dd 100644 --- a/sig/lib/appium_lib_core/common/device/keyevent.rbs +++ b/sig/lib/appium_lib_core/common/device/keyevent.rbs @@ -3,7 +3,7 @@ module Appium class Base module Device module KeyEvent - def execute: (Symbol command, ?Hash[untyped, untyped], ?Hash[untyped, untyped]) -> untyped + include _Bridge def keyevent: (untyped key, ?untyped? metastate) -> untyped diff --git a/sig/lib/appium_lib_core/common/device/screen_record.rbs b/sig/lib/appium_lib_core/common/device/screen_record.rbs index 40200222..0997f0f5 100644 --- a/sig/lib/appium_lib_core/common/device/screen_record.rbs +++ b/sig/lib/appium_lib_core/common/device/screen_record.rbs @@ -7,12 +7,16 @@ module Appium attr_reader upload_option: untyped - METHOD: ::Array["POST" | "PUT"] + METHOD: ::Array[::String] - def initialize: (?remote_path: untyped?, ?user: untyped?, ?pass: untyped?, ?method: ::String, ?file_field_name: untyped?, ?form_fields: untyped?, ?headers: untyped?, ?force_restart: untyped?) -> void + type upload_method = "POST" | "PUT" | "post" | "put" + + def initialize: (?remote_path: untyped?, ?user: untyped?, ?pass: untyped?, ?method: upload_method, ?file_field_name: untyped?, ?form_fields: untyped?, ?headers: untyped?, ?force_restart: untyped?) -> void module Command - def stop_recording_screen: (?remote_path: untyped?, ?user: untyped?, ?pass: untyped?, ?method: ::String, ?file_field_name: untyped?, ?form_fields: untyped?, ?headers: untyped?) -> untyped + include _Bridge + + def stop_recording_screen: (?remote_path: untyped?, ?user: untyped?, ?pass: untyped?, ?method: upload_method, ?file_field_name: untyped?, ?form_fields: untyped?, ?headers: untyped?) -> untyped def stop_and_save_recording_screen: (untyped file_path) -> untyped end diff --git a/sig/lib/appium_lib_core/driver.rbs b/sig/lib/appium_lib_core/driver.rbs index 7557396b..894b0e00 100644 --- a/sig/lib/appium_lib_core/driver.rbs +++ b/sig/lib/appium_lib_core/driver.rbs @@ -1,5 +1,14 @@ module Appium - Location: Class + # Struct for device location + class Location + attr_accessor latitude: Float | Integer | String + + attr_accessor longitude: Float | Integer | String + + attr_accessor altitude: Float | Integer | String + + def initialize: (Float | Integer | String latitude, Float | Integer | String longitude, Float | Integer | String altitude) -> void + end module Core module Android @@ -41,7 +50,7 @@ module Appium attr_reader enable_idempotency_header: bool - def initialize: (Hash[Symbol, String] appium_lib_opts) -> void + def initialize: (Hash[Symbol, untyped] appium_lib_opts) -> void private @@ -79,7 +88,7 @@ module Appium @custom_url: String - @caps: Hash[Symbol | String, Symbol | String | Integer] + @caps: Core::Base::Capabilities @http_client: Core::Base::Http::Default @@ -172,25 +181,25 @@ module Appium extend Core::Device - def get_caps: (Hash[Symbol, Symbol | String | Hash[Symbol, String | Numeric] | Numeric]? opts) - -> Core::Base::Capabilities + def get_caps: (Hash[Symbol, untyped]? opts) -> Core::Base::Capabilities - def get_appium_lib_opts: (Hash[Symbol, Symbol | String | Hash[Symbol, String | Numeric] | Numeric]? opts) - -> (Symbol | String | Hash[Symbol, String | Numeric] | Numeric) + def get_appium_lib_opts: (Hash[Symbol, untyped]? opts) -> Hash[Symbol, untyped] def get_app: () -> String? def set_app_path: () -> String? def set_appium_lib_specific_values: ( - Hash[Symbol, String] appium_lib_opts + Hash[Symbol, String | Numeric] appium_lib_opts ) -> bool - def set_appium_device: () -> Symbol + def set_appium_device: () -> Symbol? def set_automation_name: () -> Symbol? - def convert_downcase: (Symbol value) -> Symbol + def get_cap: (String | Symbol name) -> untyped + + def convert_downcase: (String | Symbol value) -> Symbol end end end diff --git a/sig/lib/appium_lib_core/element.rbs b/sig/lib/appium_lib_core/element.rbs index 42c1f37e..7a76c0dd 100644 --- a/sig/lib/appium_lib_core/element.rbs +++ b/sig/lib/appium_lib_core/element.rbs @@ -1,13 +1,16 @@ module Appium module Core + # Element class inheriting from Selenium::WebDriver::Element class Element < ::Selenium::WebDriver::Element include ::Appium::Core::Base::TakesScreenshot - attr_reader id: untyped + def initialize: (untyped bridge, untyped id) -> void + + attr_reader id: Array[untyped] def method_missing: (untyped method_name, *untyped args) { (?) -> untyped } -> (nil | untyped) - def respond_to_missing?: (*untyped) -> true + def respond_to_missing?: (untyped _method_name, bool _include_private) -> true # Alias for type alias type send_keys diff --git a/sig/lib/appium_lib_core/ios/clipboard.rbs b/sig/lib/appium_lib_core/ios/device/clipboard.rbs similarity index 58% rename from sig/lib/appium_lib_core/ios/clipboard.rbs rename to sig/lib/appium_lib_core/ios/device/clipboard.rbs index 6e78e587..7c89b596 100644 --- a/sig/lib/appium_lib_core/ios/clipboard.rbs +++ b/sig/lib/appium_lib_core/ios/device/clipboard.rbs @@ -5,11 +5,7 @@ module Appium module Clipboard include _Bridge - def execute: (Symbol command, ?Hash[untyped, untyped], ?Hash[untyped, untyped]) -> untyped - def self.add_methods: () -> untyped - - def self.touch_id: -> untyped end end end diff --git a/sig/lib/appium_lib_core/ios/xcuitest/device/battery.rbs b/sig/lib/appium_lib_core/ios/xcuitest/device/battery.rbs index 1e30ce52..9fb40f90 100644 --- a/sig/lib/appium_lib_core/ios/xcuitest/device/battery.rbs +++ b/sig/lib/appium_lib_core/ios/xcuitest/device/battery.rbs @@ -4,9 +4,11 @@ module Appium module Xcuitest module Device module Battery + include _Bridge + def self.add_methods: () -> (Symbol | Hash[Symbol, Proc])? - def battery_info: () -> (Symbol | Hash[Symbol, Proc])? + def battery_info: () -> ::Hash[::Symbol, ::Symbol] end end end diff --git a/sig/lib/appium_lib_core/ios/xcuitest/device/performance.rbs b/sig/lib/appium_lib_core/ios/xcuitest/device/performance.rbs index 067639ba..5702df18 100644 --- a/sig/lib/appium_lib_core/ios/xcuitest/device/performance.rbs +++ b/sig/lib/appium_lib_core/ios/xcuitest/device/performance.rbs @@ -4,6 +4,8 @@ module Appium module Xcuitest module Device module Performance + include _Bridge + def self.add_methods: () -> untyped end end