From 84e91e8c35b3d74e922b3d9b78414c817b587969 Mon Sep 17 00:00:00 2001 From: aguspe Date: Thu, 17 Oct 2024 14:55:10 +0200 Subject: [PATCH 1/2] Reduce steep issues from 87 to 65 --- rb/sig/lib/selenium/webdriver/bidi.rbs | 2 ++ .../selenium/webdriver/bidi/log_handler.rbs | 29 +++++++++++++++++++ rb/sig/lib/selenium/webdriver/bidi/struct.rbs | 11 +++++++ .../webdriver/common/websocket_connection.rbs | 2 ++ .../selenium/webdriver/remote/bidi_bridge.rbs | 17 +++++++++++ .../lib/selenium/webdriver/remote/bridge.rbs | 2 ++ .../remote/bridge/locator_converter.rbs | 19 ++++++++++++ 7 files changed, 82 insertions(+) create mode 100644 rb/sig/lib/selenium/webdriver/bidi/log_handler.rbs create mode 100644 rb/sig/lib/selenium/webdriver/bidi/struct.rbs create mode 100644 rb/sig/lib/selenium/webdriver/remote/bidi_bridge.rbs create mode 100644 rb/sig/lib/selenium/webdriver/remote/bridge/locator_converter.rbs diff --git a/rb/sig/lib/selenium/webdriver/bidi.rbs b/rb/sig/lib/selenium/webdriver/bidi.rbs index 109b658bca24b..30615c971650e 100644 --- a/rb/sig/lib/selenium/webdriver/bidi.rbs +++ b/rb/sig/lib/selenium/webdriver/bidi.rbs @@ -11,6 +11,8 @@ module Selenium def callbacks: () -> Hash[untyped, untyped] + def remove_callback: -> untyped + def session: () -> Session def send_cmd: (untyped method, **untyped params) -> untyped diff --git a/rb/sig/lib/selenium/webdriver/bidi/log_handler.rbs b/rb/sig/lib/selenium/webdriver/bidi/log_handler.rbs new file mode 100644 index 0000000000000..14da139a52c8c --- /dev/null +++ b/rb/sig/lib/selenium/webdriver/bidi/log_handler.rbs @@ -0,0 +1,29 @@ +module Selenium + module WebDriver + class BiDi + class LogHandler + @bidi: untyped + + @log_entry_subscribed: untyped + + ConsoleLogEntry: untyped + + JavaScriptLogEntry: untyped + + def initialize: (untyped bidi) -> void + + # @return [int] id of the handler + def add_message_handler: (untyped type) { (untyped) -> untyped } -> untyped + + # @param [int] id of the handler previously added + def remove_message_handler: (untyped id) -> untyped + + private + + def subscribe_log_entry: () -> untyped + + def unsubscribe_log_entry: () -> untyped + end + end + end +end diff --git a/rb/sig/lib/selenium/webdriver/bidi/struct.rbs b/rb/sig/lib/selenium/webdriver/bidi/struct.rbs new file mode 100644 index 0000000000000..6fb893dd7e46d --- /dev/null +++ b/rb/sig/lib/selenium/webdriver/bidi/struct.rbs @@ -0,0 +1,11 @@ +module Selenium + module WebDriver + class BiDi + class Struct < ::Struct + def self.new: (*untyped args) { (?) -> untyped } -> void + + def self.camel_to_snake: (String camel_str) -> String + end + end + end +end diff --git a/rb/sig/lib/selenium/webdriver/common/websocket_connection.rbs b/rb/sig/lib/selenium/webdriver/common/websocket_connection.rbs index 411f09d91e948..4153dda6a615f 100644 --- a/rb/sig/lib/selenium/webdriver/common/websocket_connection.rbs +++ b/rb/sig/lib/selenium/webdriver/common/websocket_connection.rbs @@ -35,6 +35,8 @@ module Selenium def initialize: (url: untyped) -> void + def add_callback: -> untyped + def close: () -> untyped def callbacks: () -> untyped diff --git a/rb/sig/lib/selenium/webdriver/remote/bidi_bridge.rbs b/rb/sig/lib/selenium/webdriver/remote/bidi_bridge.rbs new file mode 100644 index 0000000000000..c39c661f02cff --- /dev/null +++ b/rb/sig/lib/selenium/webdriver/remote/bidi_bridge.rbs @@ -0,0 +1,17 @@ +module Selenium + module WebDriver + module Remote + class BiDiBridge < Bridge + @bidi: untyped + + attr_reader bidi: untyped + + def create_session: (untyped capabilities) -> untyped + + def quit: () -> untyped + + def close: () -> untyped + end + end + end +end diff --git a/rb/sig/lib/selenium/webdriver/remote/bridge.rbs b/rb/sig/lib/selenium/webdriver/remote/bridge.rbs index 4e06cbd61ed7e..b56d1b9c14439 100644 --- a/rb/sig/lib/selenium/webdriver/remote/bridge.rbs +++ b/rb/sig/lib/selenium/webdriver/remote/bridge.rbs @@ -32,6 +32,8 @@ module Selenium def initialize: (url: String | URI, ?http_client: untyped?) -> void + def bidi: -> untyped + def cancel_fedcm_dialog: -> nil def click_fedcm_dialog_button: -> nil diff --git a/rb/sig/lib/selenium/webdriver/remote/bridge/locator_converter.rbs b/rb/sig/lib/selenium/webdriver/remote/bridge/locator_converter.rbs new file mode 100644 index 0000000000000..5a6b4c7f89d49 --- /dev/null +++ b/rb/sig/lib/selenium/webdriver/remote/bridge/locator_converter.rbs @@ -0,0 +1,19 @@ +module Selenium + module WebDriver + module Remote + class Bridge + class LocatorConverter + ESCAPE_CSS_REGEXP: ::Regexp + + UNICODE_CODE_POINT: 30 + + def convert: (untyped how, untyped what) -> ::Array[untyped] + + private + + def escape_css: (untyped string) -> untyped + end + end + end + end +end From a52a22f0cdfe08e850f8d4a84e4626fdebad01cc Mon Sep 17 00:00:00 2001 From: aguspe Date: Thu, 17 Oct 2024 15:08:31 +0200 Subject: [PATCH 2/2] Update types --- rb/sig/lib/selenium/webdriver/bidi.rbs | 6 ++++-- .../selenium/webdriver/bidi/log_handler.rbs | 20 +++++++++---------- .../webdriver/common/websocket_connection.rbs | 2 -- .../selenium/webdriver/remote/bidi_bridge.rbs | 6 +++--- .../lib/selenium/webdriver/remote/bridge.rbs | 2 +- .../remote/bridge/locator_converter.rbs | 8 ++++---- 6 files changed, 21 insertions(+), 23 deletions(-) diff --git a/rb/sig/lib/selenium/webdriver/bidi.rbs b/rb/sig/lib/selenium/webdriver/bidi.rbs index 30615c971650e..fa6b8757f6815 100644 --- a/rb/sig/lib/selenium/webdriver/bidi.rbs +++ b/rb/sig/lib/selenium/webdriver/bidi.rbs @@ -7,15 +7,17 @@ module Selenium def initialize: (url: String) -> void + def add_callback: -> Integer + def close: () -> nil def callbacks: () -> Hash[untyped, untyped] - def remove_callback: -> untyped + def remove_callback: -> Array[Integer] def session: () -> Session - def send_cmd: (untyped method, **untyped params) -> untyped + def send_cmd: (String method, **untyped params) -> untyped def error_message: (Hash[String,String] message) -> String end diff --git a/rb/sig/lib/selenium/webdriver/bidi/log_handler.rbs b/rb/sig/lib/selenium/webdriver/bidi/log_handler.rbs index 14da139a52c8c..703729d9c74ec 100644 --- a/rb/sig/lib/selenium/webdriver/bidi/log_handler.rbs +++ b/rb/sig/lib/selenium/webdriver/bidi/log_handler.rbs @@ -2,27 +2,25 @@ module Selenium module WebDriver class BiDi class LogHandler - @bidi: untyped + @bidi: BiDi - @log_entry_subscribed: untyped + @log_entry_subscribed: bool - ConsoleLogEntry: untyped + ConsoleLogEntry: Struct - JavaScriptLogEntry: untyped + JavaScriptLogEntry: Struct - def initialize: (untyped bidi) -> void + def initialize: (BiDi bidi) -> void - # @return [int] id of the handler - def add_message_handler: (untyped type) { (untyped) -> untyped } -> untyped + def add_message_handler: (String type) { (untyped) -> untyped } -> Integer - # @param [int] id of the handler previously added - def remove_message_handler: (untyped id) -> untyped + def remove_message_handler: (Integer id) -> false private - def subscribe_log_entry: () -> untyped + def subscribe_log_entry: () -> false - def unsubscribe_log_entry: () -> untyped + def unsubscribe_log_entry: () -> false end end end diff --git a/rb/sig/lib/selenium/webdriver/common/websocket_connection.rbs b/rb/sig/lib/selenium/webdriver/common/websocket_connection.rbs index 4153dda6a615f..411f09d91e948 100644 --- a/rb/sig/lib/selenium/webdriver/common/websocket_connection.rbs +++ b/rb/sig/lib/selenium/webdriver/common/websocket_connection.rbs @@ -35,8 +35,6 @@ module Selenium def initialize: (url: untyped) -> void - def add_callback: -> untyped - def close: () -> untyped def callbacks: () -> untyped diff --git a/rb/sig/lib/selenium/webdriver/remote/bidi_bridge.rbs b/rb/sig/lib/selenium/webdriver/remote/bidi_bridge.rbs index c39c661f02cff..cbb4fc665eb09 100644 --- a/rb/sig/lib/selenium/webdriver/remote/bidi_bridge.rbs +++ b/rb/sig/lib/selenium/webdriver/remote/bidi_bridge.rbs @@ -6,11 +6,11 @@ module Selenium attr_reader bidi: untyped - def create_session: (untyped capabilities) -> untyped + def create_session: (Hash[Symbol, String] capabilities) -> BiDi - def quit: () -> untyped + def quit: () -> nil - def close: () -> untyped + def close: () -> nil end end end diff --git a/rb/sig/lib/selenium/webdriver/remote/bridge.rbs b/rb/sig/lib/selenium/webdriver/remote/bridge.rbs index b56d1b9c14439..70520fd5f3aa1 100644 --- a/rb/sig/lib/selenium/webdriver/remote/bridge.rbs +++ b/rb/sig/lib/selenium/webdriver/remote/bridge.rbs @@ -32,7 +32,7 @@ module Selenium def initialize: (url: String | URI, ?http_client: untyped?) -> void - def bidi: -> untyped + def bidi: -> WebDriver::Error::WebDriverError def cancel_fedcm_dialog: -> nil diff --git a/rb/sig/lib/selenium/webdriver/remote/bridge/locator_converter.rbs b/rb/sig/lib/selenium/webdriver/remote/bridge/locator_converter.rbs index 5a6b4c7f89d49..3e2b15b82b84a 100644 --- a/rb/sig/lib/selenium/webdriver/remote/bridge/locator_converter.rbs +++ b/rb/sig/lib/selenium/webdriver/remote/bridge/locator_converter.rbs @@ -3,15 +3,15 @@ module Selenium module Remote class Bridge class LocatorConverter - ESCAPE_CSS_REGEXP: ::Regexp + ESCAPE_CSS_REGEXP: Regexp - UNICODE_CODE_POINT: 30 + UNICODE_CODE_POINT: Integer - def convert: (untyped how, untyped what) -> ::Array[untyped] + def convert: (String | Symbol how, String what) -> Array[String] private - def escape_css: (untyped string) -> untyped + def escape_css: (String string) -> String end end end