Skip to content

Commit e672104

Browse files
authored
[rb] Expand RBS typing support by replacing untypes with precise typing (#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]>
1 parent 635f7e2 commit e672104

File tree

12 files changed

+59
-59
lines changed

12 files changed

+59
-59
lines changed

rb/sig/lib/selenium/server.rbs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@ module Selenium
44

55
self.@available_assets: untyped
66

7-
@jar: untyped
7+
@jar: String
88

9-
@host: untyped
9+
@host: String
1010

11-
@role: untyped
11+
@role: String
1212

13-
@port: untyped
13+
@port: Integer
1414

15-
@timeout: untyped
15+
@timeout: Integer
1616

17-
@background: untyped
17+
@background: bool
1818

19-
@additional_args: untyped
19+
@additional_args: Integer | bool | Array[untyped]
2020

21-
@log: untyped
21+
@log: String | bool
2222

2323
@log_file: untyped
2424

2525
@process: untyped
2626

27-
@socket: untyped
27+
@socket: WebDriver::SocketPoller
2828

2929
class Error < StandardError
3030
end
3131

3232
CL_RESET: untyped
3333

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

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

3838
def self.latest: () -> untyped
3939

@@ -55,7 +55,7 @@ module Selenium
5555

5656
attr_accessor log: untyped
5757

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

6060
def start: () -> untyped
6161

rb/sig/lib/selenium/webdriver/atoms.rbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ module Selenium
44
include _Bridge
55
include _ExecuteScript
66

7-
def atom_script: (untyped) -> untyped
7+
def atom_script: (Symbol) -> String
88

99
private
1010

1111
def read_atom: (Symbol function) -> String
1212

13-
def execute_atom: (Symbol function_name, *untyped arguments) -> untyped
13+
def execute_atom: (Symbol function_name, [Element | String | Symbol] arguments) -> [Element | Integer | Float | bool | nil | String | Array[untyped]]
1414
end
1515
end
1616
end
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
module Selenium
22
module WebDriver
33
class BiDi
4-
@ws: untyped
4+
@ws: WebSocketConnection
55

6-
@session: untyped
6+
@session: Session
77

8-
def initialize: (url: untyped) -> void
8+
def initialize: (url: String) -> void
99

10-
def close: () -> untyped
10+
def close: () -> nil
1111

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

14-
def session: () -> untyped
14+
def session: () -> Session
1515

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

18-
def error_message: (untyped message) -> ::String
18+
def error_message: (Hash[String,String] message) -> String
1919
end
2020
end
2121
end

rb/sig/lib/selenium/webdriver/chrome/features.rbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ module Selenium
44
module Features
55
include WebDriver::Chromium::Features
66

7-
CHROME_COMMANDS: untyped
8-
COMMANDS: Array[Symbol | String]
7+
CHROME_COMMANDS: Hash[Symbol, Array[Symbol | String]]
8+
COMMANDS: Hash[Symbol, Array[Symbol | String]]
99

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

1212
def commands: (Symbol command) -> Array[Symbol | String]
1313
end
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
module Selenium
22
module WebDriver
33
class Options
4-
@options: untyped
4+
@options: Hash[String | Symbol, String | Numeric | bool?]
55

66
W3C_OPTIONS: Array[Symbol]
77

88
GRID_OPTIONS: Array[Symbol]
99

10-
BROWSER: untyped
10+
BROWSER: Symbol
1111

1212
KEY: untyped
1313

14-
CAPABILITIES: Hash[Symbol, String]
14+
CAPABILITIES: Hash[String | Symbol, String | Numeric | bool?]
1515

16-
attr_reader self.driver_path: untyped
16+
attr_reader self.driver_path: String
1717

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

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

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

2424
alias self.internet_explorer self.ie
2525

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

2828
alias self.microsoftedge self.edge
2929

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

3232
def self.set_capabilities: () -> untyped
3333

34-
attr_accessor options: untyped
34+
attr_accessor options: Hash[String | Symbol, String | Numeric | bool?]
3535

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

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

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

4242
alias eql? ==
4343

@@ -53,13 +53,14 @@ module Selenium
5353

5454
def camelize?: (untyped _key) -> true
5555

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

58-
def process_json_hash: (untyped value, untyped camelize_keys) -> untyped
59+
def process_json_hash: (Hash[untyped, untyped] value, bool camelize_keys) -> Hash[untyped, untyped]
5960

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

62-
def camel_case: (untyped str) -> untyped
63+
def camel_case: (String str) -> String
6364
end
6465
end
6566
end

rb/sig/lib/selenium/webdriver/common/target_locator.rbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ module Selenium
77

88
def parent_frame: () -> void
99

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

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

1414
def active_element: () -> Element
1515

rb/sig/lib/selenium/webdriver/devtools.rbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Selenium
1010

1111
def initialize: (url: untyped) -> void
1212

13-
def close: () -> untyped
13+
def close: () -> nil
1414

1515
def callbacks: () -> untyped
1616

@@ -24,7 +24,7 @@ module Selenium
2424

2525
def start_session: () -> untyped
2626

27-
def error_message: (untyped error) -> untyped
27+
def error_message: (Hash[untyped, untyped] error) -> String
2828
end
2929
end
3030
end
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module Selenium
22
module WebDriver
33
module Edge
4-
self.@path: untyped
4+
@path: String?
55

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

8-
def self.path: () -> untyped
8+
def self.path: () -> String?
99
end
1010
end
1111
end

rb/sig/lib/selenium/webdriver/firefox.rbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Selenium
22
module WebDriver
33
module Firefox
4-
self.@path: untyped
4+
@path: String?
55

66
DEFAULT_PORT: Integer
77

@@ -13,9 +13,9 @@ module Selenium
1313

1414
DEVTOOLS_VERSION: Integer
1515

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

18-
def self.path: () -> untyped
18+
def self.path: () -> String?
1919
end
2020
end
2121
end
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
module Selenium
22
module WebDriver
33
module Safari
4-
self.@use_technology_preview: untyped
4+
@use_technology_preview: bool?
5+
@path: String?
56

6-
self.@path: untyped
7-
8-
attr_accessor self.use_technology_preview: untyped
7+
attr_accessor self.use_technology_preview: bool
98

109
def self.technology_preview: () -> String
1110

12-
def self.technology_preview!: () -> untyped
11+
def self.technology_preview!: () -> bool
1312

14-
def self.technology_preview?: () -> untyped
13+
def self.technology_preview?: () -> bool
1514

16-
def self.path=: (untyped path) -> untyped
15+
def self.path=: (String) -> String
1716

18-
def self.path: () -> untyped
17+
def self.path: () -> String
1918
end
2019
end
2120
end

0 commit comments

Comments
 (0)