Skip to content

Commit

Permalink
[rb] Expand RBS typing support by replacing untypes with precise typi…
Browse files Browse the repository at this point in the history
…ng (#13709)

* Update atoms.rb signature types

* Start adding bidi types

* Extended types of devtools and edge

* Added firefox and safari types and removed unused signature

* Update chrome features with type and remove Safari error

* Update server and remove unused signature

* Expand Server type signature

* expanding type support on options

* Expand options types

* add extra options support

* Expand options support

---------

Co-authored-by: aguspe <[email protected]>
  • Loading branch information
aguspe and aguspe authored Jun 4, 2024
1 parent 635f7e2 commit e672104
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 59 deletions.
24 changes: 12 additions & 12 deletions rb/sig/lib/selenium/server.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ module Selenium

self.@available_assets: untyped

@jar: untyped
@jar: String

@host: untyped
@host: String

@role: untyped
@role: String

@port: untyped
@port: Integer

@timeout: untyped
@timeout: Integer

@background: untyped
@background: bool

@additional_args: untyped
@additional_args: Integer | bool | Array[untyped]

@log: untyped
@log: String | bool

@log_file: untyped

@process: untyped

@socket: untyped
@socket: WebDriver::SocketPoller

class Error < StandardError
end

CL_RESET: untyped

def self.get: (?Symbol required_version, ?Hash[untyped, untyped] opts) -> untyped
def self.get: (Symbol | String required_version, ?Hash[untyped, untyped] opts) -> Server

def self.download: (?Symbol required_version) -> untyped
def self.download: (Symbol | String required_version) -> String

def self.latest: () -> untyped

Expand All @@ -55,7 +55,7 @@ module Selenium

attr_accessor log: untyped

def initialize: (untyped jar, ?Hash[untyped, untyped] opts) -> void
def initialize: (String jar, ?Hash[String | Symbol, Integer | bool] opts) -> void

def start: () -> untyped

Expand Down
4 changes: 2 additions & 2 deletions rb/sig/lib/selenium/webdriver/atoms.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ module Selenium
include _Bridge
include _ExecuteScript

def atom_script: (untyped) -> untyped
def atom_script: (Symbol) -> String

private

def read_atom: (Symbol function) -> String

def execute_atom: (Symbol function_name, *untyped arguments) -> untyped
def execute_atom: (Symbol function_name, [Element | String | Symbol] arguments) -> [Element | Integer | Float | bool | nil | String | Array[untyped]]
end
end
end
14 changes: 7 additions & 7 deletions rb/sig/lib/selenium/webdriver/bidi.rbs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
module Selenium
module WebDriver
class BiDi
@ws: untyped
@ws: WebSocketConnection

@session: untyped
@session: Session

def initialize: (url: untyped) -> void
def initialize: (url: String) -> void

def close: () -> untyped
def close: () -> nil

def callbacks: () -> untyped
def callbacks: () -> Hash[untyped, untyped]

def session: () -> untyped
def session: () -> Session

def send_cmd: (untyped method, **untyped params) -> untyped

def error_message: (untyped message) -> ::String
def error_message: (Hash[String,String] message) -> String
end
end
end
6 changes: 3 additions & 3 deletions rb/sig/lib/selenium/webdriver/chrome/features.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module Selenium
module Features
include WebDriver::Chromium::Features

CHROME_COMMANDS: untyped
COMMANDS: Array[Symbol | String]
CHROME_COMMANDS: Hash[Symbol, Array[Symbol | String]]
COMMANDS: Hash[Symbol, Array[Symbol | String]]

def command_list: -> untyped
def command_list: -> Hash[Symbol, Array[Symbol | String]]

def commands: (Symbol command) -> Array[Symbol | String]
end
Expand Down
35 changes: 18 additions & 17 deletions rb/sig/lib/selenium/webdriver/common/options.rbs
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
module Selenium
module WebDriver
class Options
@options: untyped
@options: Hash[String | Symbol, String | Numeric | bool?]

W3C_OPTIONS: Array[Symbol]

GRID_OPTIONS: Array[Symbol]

BROWSER: untyped
BROWSER: Symbol

KEY: untyped

CAPABILITIES: Hash[Symbol, String]
CAPABILITIES: Hash[String | Symbol, String | Numeric | bool?]

attr_reader self.driver_path: untyped
attr_reader self.driver_path: String

def self.chrome: (**untyped opts) -> untyped
def self.chrome: (**String | Symbol | Integer | bool opts) -> Chrome::Options

def self.firefox: (**untyped opts) -> untyped
def self.firefox: (**String | Symbol | Integer | bool opts) -> Firefox::Options

def self.ie: (**untyped opts) -> untyped
def self.ie: (**String | Symbol | Integer | bool opts) -> IE::Options

alias self.internet_explorer self.ie

def self.edge: (**untyped opts) -> untyped
def self.edge: (**String | Symbol | Integer | bool opts) -> Edge::Options

alias self.microsoftedge self.edge

def self.safari: (**untyped opts) -> untyped
def self.safari: (**String | Symbol | Integer | bool opts) -> Safari::Options

def self.set_capabilities: () -> untyped

attr_accessor options: untyped
attr_accessor options: Hash[String | Symbol, String | Numeric | bool?]

def initialize: (**untyped opts) -> void
def initialize: (Hash[String | Symbol, String | Numeric | bool] opts) -> void

def add_option: (untyped name, ?untyped? value) -> untyped
def add_option: (String | Symbol name, String | Numeric | bool? value) -> (String | Numeric | bool)?

def ==: (untyped other) -> (false | untyped)
def ==: (untyped other) -> bool

alias eql? ==

Expand All @@ -53,13 +53,14 @@ module Selenium

def camelize?: (untyped _key) -> true

def generate_as_json: (untyped value, ?camelize_keys: bool) -> untyped
def generate_as_json: (Array[untyped] | Hash[untyped, untyped] | String | Symbol value, ?camelize_keys: bool)
-> (Array[untyped] | Hash[untyped, untyped] | String | Symbol)

def process_json_hash: (untyped value, untyped camelize_keys) -> untyped
def process_json_hash: (Hash[untyped, untyped] value, bool camelize_keys) -> Hash[untyped, untyped]

def convert_json_key: (untyped key, ?camelize: bool) -> untyped
def convert_json_key: (String | Symbol key, camelize: bool) -> String

def camel_case: (untyped str) -> untyped
def camel_case: (String str) -> String
end
end
end
4 changes: 2 additions & 2 deletions rb/sig/lib/selenium/webdriver/common/target_locator.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ module Selenium

def parent_frame: () -> void

def new_window: (?::Symbol `type`) { (untyped) -> untyped } -> untyped
def new_window: (Symbol type) { (untyped) -> untyped } -> untyped

def window: (untyped id) ?{ () -> untyped } -> untyped
def window: (Integer id) ?{ () -> untyped } -> untyped

def active_element: () -> Element

Expand Down
4 changes: 2 additions & 2 deletions rb/sig/lib/selenium/webdriver/devtools.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Selenium

def initialize: (url: untyped) -> void

def close: () -> untyped
def close: () -> nil

def callbacks: () -> untyped

Expand All @@ -24,7 +24,7 @@ module Selenium

def start_session: () -> untyped

def error_message: (untyped error) -> untyped
def error_message: (Hash[untyped, untyped] error) -> String
end
end
end
6 changes: 3 additions & 3 deletions rb/sig/lib/selenium/webdriver/edge.rbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module Selenium
module WebDriver
module Edge
self.@path: untyped
@path: String?

def self.path=: (untyped path) -> untyped
def self.path=: (String path) -> String

def self.path: () -> untyped
def self.path: () -> String?
end
end
end
6 changes: 3 additions & 3 deletions rb/sig/lib/selenium/webdriver/firefox.rbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Selenium
module WebDriver
module Firefox
self.@path: untyped
@path: String?

DEFAULT_PORT: Integer

Expand All @@ -13,9 +13,9 @@ module Selenium

DEVTOOLS_VERSION: Integer

def self.path=: (untyped path) -> untyped
def self.path=: (String path) -> String

def self.path: () -> untyped
def self.path: () -> String?
end
end
end
15 changes: 7 additions & 8 deletions rb/sig/lib/selenium/webdriver/safari.rbs
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
module Selenium
module WebDriver
module Safari
self.@use_technology_preview: untyped
@use_technology_preview: bool?
@path: String?

self.@path: untyped

attr_accessor self.use_technology_preview: untyped
attr_accessor self.use_technology_preview: bool

def self.technology_preview: () -> String

def self.technology_preview!: () -> untyped
def self.technology_preview!: () -> bool

def self.technology_preview?: () -> untyped
def self.technology_preview?: () -> bool

def self.path=: (untyped path) -> untyped
def self.path=: (String) -> String

def self.path: () -> untyped
def self.path: () -> String
end
end
end
Empty file.
Empty file removed rb/sig/lib/selenium_webdriver.rbs
Empty file.

0 comments on commit e672104

Please sign in to comment.