selenium-webdriver 4.1.0 → 4.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +261 -1
  3. data/Gemfile +2 -0
  4. data/LICENSE +1 -1
  5. data/NOTICE +1 -1
  6. data/README.md +2 -2
  7. data/bin/linux/selenium-manager +0 -0
  8. data/bin/macos/selenium-manager +0 -0
  9. data/bin/windows/selenium-manager.exe +0 -0
  10. data/lib/selenium/server.rb +36 -39
  11. data/lib/selenium/webdriver/atoms/findElements.js +3 -4
  12. data/lib/selenium/webdriver/atoms/getAttribute.js +0 -0
  13. data/lib/selenium/webdriver/atoms/isDisplayed.js +0 -0
  14. data/lib/selenium/webdriver/atoms/mutationListener.js +0 -0
  15. data/lib/selenium/webdriver/atoms.rb +2 -3
  16. data/lib/selenium/webdriver/bidi/browsing_context.rb +88 -0
  17. data/lib/selenium/webdriver/bidi/browsing_context_info.rb +35 -0
  18. data/lib/selenium/webdriver/bidi/log/base_log_entry.rb +35 -0
  19. data/lib/selenium/webdriver/bidi/log/console_log_entry.rb +35 -0
  20. data/lib/selenium/webdriver/bidi/log/filter_by.rb +40 -0
  21. data/lib/selenium/webdriver/bidi/log/generic_log_entry.rb +33 -0
  22. data/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb +33 -0
  23. data/lib/selenium/webdriver/bidi/log_inspector.rb +143 -0
  24. data/lib/selenium/webdriver/bidi/navigate_result.rb +33 -0
  25. data/lib/selenium/webdriver/bidi/session.rb +51 -0
  26. data/lib/selenium/webdriver/bidi.rb +56 -0
  27. data/lib/selenium/webdriver/chrome/driver.rb +9 -29
  28. data/lib/selenium/webdriver/chrome/features.rb +6 -68
  29. data/lib/selenium/webdriver/chrome/options.rb +3 -223
  30. data/lib/selenium/webdriver/chrome/profile.rb +3 -83
  31. data/lib/selenium/webdriver/chrome/service.rb +0 -22
  32. data/lib/selenium/webdriver/chrome.rb +0 -14
  33. data/lib/selenium/webdriver/chromium/driver.rb +61 -0
  34. data/lib/selenium/webdriver/chromium/features.rb +103 -0
  35. data/lib/selenium/webdriver/chromium/options.rb +243 -0
  36. data/lib/selenium/webdriver/chromium/profile.rb +113 -0
  37. data/lib/selenium/webdriver/chromium.rb +31 -0
  38. data/lib/selenium/webdriver/common/action_builder.rb +64 -22
  39. data/lib/selenium/webdriver/common/child_process.rb +124 -0
  40. data/lib/selenium/webdriver/common/driver.rb +36 -74
  41. data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +0 -2
  42. data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +0 -1
  43. data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +0 -2
  44. data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +0 -2
  45. data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +0 -2
  46. data/lib/selenium/webdriver/common/driver_extensions/{has_remote_status.rb → has_bidi.rb} +10 -5
  47. data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +10 -1
  48. data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +0 -2
  49. data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +1 -4
  50. data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +0 -2
  51. data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +0 -2
  52. data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +0 -2
  53. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +1 -2
  54. data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +1 -2
  55. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +0 -2
  56. data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +2 -69
  57. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +0 -2
  58. data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +1 -3
  59. data/lib/selenium/webdriver/common/driver_finder.rb +45 -0
  60. data/lib/selenium/webdriver/common/element.rb +8 -8
  61. data/lib/selenium/webdriver/common/error.rb +28 -5
  62. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +2 -2
  63. data/lib/selenium/webdriver/common/interactions/input_device.rb +10 -4
  64. data/lib/selenium/webdriver/common/interactions/interaction.rb +12 -25
  65. data/lib/selenium/webdriver/common/interactions/interactions.rb +24 -4
  66. data/lib/selenium/webdriver/common/interactions/key_actions.rb +5 -1
  67. data/lib/selenium/webdriver/common/interactions/key_input.rb +11 -27
  68. data/lib/selenium/webdriver/common/interactions/none_input.rb +10 -8
  69. data/lib/selenium/webdriver/common/interactions/pause.rb +49 -0
  70. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +59 -70
  71. data/lib/selenium/webdriver/common/interactions/pointer_cancel.rb +45 -0
  72. data/lib/selenium/webdriver/common/interactions/pointer_event_properties.rb +63 -0
  73. data/lib/selenium/webdriver/common/interactions/pointer_input.rb +15 -84
  74. data/lib/selenium/webdriver/common/interactions/pointer_move.rb +60 -0
  75. data/lib/selenium/webdriver/common/interactions/pointer_press.rb +85 -0
  76. data/lib/selenium/webdriver/common/interactions/scroll.rb +59 -0
  77. data/lib/selenium/webdriver/common/interactions/scroll_origin.rb +48 -0
  78. data/lib/selenium/webdriver/common/interactions/typing_interaction.rb +54 -0
  79. data/lib/selenium/webdriver/common/interactions/wheel_actions.rb +113 -0
  80. data/lib/selenium/webdriver/common/interactions/wheel_input.rb +42 -0
  81. data/lib/selenium/webdriver/common/keys.rb +1 -0
  82. data/lib/selenium/webdriver/common/local_driver.rb +55 -0
  83. data/lib/selenium/webdriver/common/logger.rb +90 -25
  84. data/lib/selenium/webdriver/common/manager.rb +0 -27
  85. data/lib/selenium/webdriver/common/options.rb +13 -17
  86. data/lib/selenium/webdriver/common/platform.rb +5 -51
  87. data/lib/selenium/webdriver/common/port_prober.rb +1 -1
  88. data/lib/selenium/webdriver/common/profile_helper.rb +1 -1
  89. data/lib/selenium/webdriver/common/proxy.rb +2 -2
  90. data/lib/selenium/webdriver/common/search_context.rb +0 -6
  91. data/lib/selenium/webdriver/common/selenium_manager.rb +131 -0
  92. data/lib/selenium/webdriver/common/service.rb +17 -30
  93. data/lib/selenium/webdriver/common/service_manager.rb +8 -15
  94. data/lib/selenium/webdriver/common/shadow_root.rb +2 -3
  95. data/lib/selenium/webdriver/common/socket_lock.rb +3 -3
  96. data/lib/selenium/webdriver/common/socket_poller.rb +2 -2
  97. data/lib/selenium/webdriver/common/takes_screenshot.rb +2 -3
  98. data/lib/selenium/webdriver/common/target_locator.rb +2 -3
  99. data/lib/selenium/webdriver/common/timeouts.rb +2 -2
  100. data/lib/selenium/webdriver/common/virtual_authenticator/credential.rb +85 -0
  101. data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator.rb +72 -0
  102. data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb +62 -0
  103. data/lib/selenium/webdriver/common/websocket_connection.rb +164 -0
  104. data/lib/selenium/webdriver/common/window.rb +6 -6
  105. data/lib/selenium/webdriver/common/zipper.rb +1 -1
  106. data/lib/selenium/webdriver/common.rb +21 -3
  107. data/lib/selenium/webdriver/devtools/console_event.rb +0 -2
  108. data/lib/selenium/webdriver/devtools/exception_event.rb +0 -2
  109. data/lib/selenium/webdriver/devtools/mutation_event.rb +0 -2
  110. data/lib/selenium/webdriver/devtools/network_interceptor.rb +173 -0
  111. data/lib/selenium/webdriver/devtools/pinned_script.rb +0 -2
  112. data/lib/selenium/webdriver/devtools/request.rb +1 -3
  113. data/lib/selenium/webdriver/devtools/response.rb +1 -3
  114. data/lib/selenium/webdriver/devtools.rb +17 -114
  115. data/lib/selenium/webdriver/edge/driver.rb +9 -3
  116. data/lib/selenium/webdriver/edge/features.rb +4 -4
  117. data/lib/selenium/webdriver/edge/options.rb +17 -5
  118. data/lib/selenium/webdriver/edge/profile.rb +2 -2
  119. data/lib/selenium/webdriver/edge/service.rb +1 -7
  120. data/lib/selenium/webdriver/firefox/driver.rb +9 -2
  121. data/lib/selenium/webdriver/firefox/features.rb +6 -6
  122. data/lib/selenium/webdriver/firefox/options.rb +6 -15
  123. data/lib/selenium/webdriver/firefox/profile.rb +8 -12
  124. data/lib/selenium/webdriver/firefox/service.rb +0 -18
  125. data/lib/selenium/webdriver/firefox/util.rb +46 -0
  126. data/lib/selenium/webdriver/firefox.rb +1 -14
  127. data/lib/selenium/webdriver/ie/driver.rb +7 -1
  128. data/lib/selenium/webdriver/ie/options.rb +2 -1
  129. data/lib/selenium/webdriver/ie/service.rb +0 -22
  130. data/lib/selenium/webdriver/ie.rb +0 -14
  131. data/lib/selenium/webdriver/remote/{commands.rb → bridge/commands.rb} +15 -8
  132. data/lib/selenium/webdriver/remote/bridge.rb +65 -35
  133. data/lib/selenium/webdriver/remote/capabilities.rb +3 -53
  134. data/lib/selenium/webdriver/remote/driver.rb +19 -14
  135. data/lib/selenium/webdriver/remote/http/common.rb +3 -3
  136. data/lib/selenium/webdriver/remote/http/curb.rb +1 -3
  137. data/lib/selenium/webdriver/remote/http/default.rb +8 -14
  138. data/lib/selenium/webdriver/remote/response.rb +2 -3
  139. data/lib/selenium/webdriver/remote/server_error.rb +1 -1
  140. data/lib/selenium/webdriver/remote.rb +0 -1
  141. data/lib/selenium/webdriver/safari/driver.rb +7 -1
  142. data/lib/selenium/webdriver/safari/features.rb +0 -2
  143. data/lib/selenium/webdriver/safari/options.rb +5 -1
  144. data/lib/selenium/webdriver/safari/service.rb +10 -4
  145. data/lib/selenium/webdriver/safari.rb +1 -15
  146. data/lib/selenium/webdriver/support/color.rb +22 -22
  147. data/lib/selenium/webdriver/support/guards/guard.rb +0 -2
  148. data/lib/selenium/webdriver/support/guards/guard_condition.rb +1 -3
  149. data/lib/selenium/webdriver/support/guards.rb +1 -1
  150. data/lib/selenium/webdriver/support/relative_locator.rb +0 -1
  151. data/lib/selenium/webdriver/support/select.rb +3 -1
  152. data/lib/selenium/webdriver/version.rb +1 -1
  153. data/lib/selenium/webdriver.rb +5 -4
  154. data/selenium-webdriver.gemspec +14 -12
  155. metadata +73 -63
  156. data/lib/selenium/webdriver/remote/http/persistent.rb +0 -65
  157. data/lib/selenium/webdriver/support/cdp/domain.rb.erb +0 -63
  158. data/lib/selenium/webdriver/support/cdp_client_generator.rb +0 -108
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ class BiDi
23
+ class BaseLogEntry
24
+ attr_accessor :level, :text, :timestamp, :stack_trace
25
+
26
+ def initialize(level:, text:, timestamp:, stack_trace:)
27
+ @level = level
28
+ @text = text
29
+ @timestamp = timestamp
30
+ @stack_trace = stack_trace
31
+ end
32
+ end # BaseLogEntry
33
+ end # BiDi
34
+ end # WebDriver
35
+ end # Selenium
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ class BiDi
23
+ class ConsoleLogEntry < GenericLogEntry
24
+ attr_accessor :method, :realm, :args
25
+
26
+ def initialize(method:, realm:, args:, **opts)
27
+ super(**opts)
28
+ @method = method
29
+ @realm = realm
30
+ @args = args
31
+ end
32
+ end # ConsoleLogEntry
33
+ end # BiDi
34
+ end # WebDriver
35
+ end # Selenium
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ class BiDi
23
+ class FilterBy
24
+ attr_accessor :level
25
+
26
+ def initialize(level)
27
+ @level = level
28
+ end
29
+
30
+ def self.log_level(level = nil)
31
+ unless %w[debug error info warning].include?(level)
32
+ raise Error::WebDriverError,
33
+ "Valid log levels are 'debug', 'error', 'info' and 'warning'. Received: #{level}"
34
+ end
35
+ FilterBy.new(level)
36
+ end
37
+ end # FilterBy
38
+ end # BiDi
39
+ end # WebDriver
40
+ end # Selenium
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ class BiDi
23
+ class GenericLogEntry < BaseLogEntry
24
+ attr_accessor :type
25
+
26
+ def initialize(level:, text:, timestamp:, type:, stack_trace:)
27
+ super(level: level, text: text, timestamp: timestamp, stack_trace: stack_trace)
28
+ @type = type
29
+ end
30
+ end # GenericLogEntry
31
+ end # BiDi
32
+ end # WebDriver
33
+ end # Selenium
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ class BiDi
23
+ class JavascriptLogEntry < GenericLogEntry
24
+ attr_accessor :type
25
+
26
+ def initialize(level:, text:, timestamp:, type:, stack_trace:)
27
+ super(level: level, text: text, timestamp: timestamp, type: type, stack_trace: stack_trace)
28
+ @type = 'javascript'
29
+ end
30
+ end # JavascriptLogEntry
31
+ end # BiDi
32
+ end # WebDriver
33
+ end # Selenium
@@ -0,0 +1,143 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ # This file is automatically generated. Any changes will be lost!
21
+
22
+ require_relative 'log/base_log_entry'
23
+ require_relative 'log/generic_log_entry'
24
+ require_relative 'log/console_log_entry'
25
+ require_relative 'log/javascript_log_entry'
26
+ require_relative 'log/filter_by'
27
+
28
+ module Selenium
29
+ module WebDriver
30
+ class BiDi
31
+ class LogInspector
32
+ EVENTS = {
33
+ entry_added: 'entryAdded'
34
+ }.freeze
35
+
36
+ LOG_LEVEL = {
37
+ DEBUG: 'debug',
38
+ ERROR: 'error',
39
+ INFO: 'info',
40
+ WARNING: 'warning'
41
+ }.freeze
42
+
43
+ def initialize(driver, browsing_context_ids = nil)
44
+ unless driver.capabilities.web_socket_url
45
+ raise Error::WebDriverError,
46
+ 'WebDriver instance must support BiDi protocol'
47
+ end
48
+
49
+ @bidi = driver.bidi
50
+ @bidi.session.subscribe('log.entryAdded', browsing_context_ids)
51
+ end
52
+
53
+ def on_console_entry(filter_by = nil, &block)
54
+ check_valid_filter(filter_by)
55
+
56
+ on_log do |params|
57
+ type = params['type']
58
+ console_log_events(params, filter_by, &block) if type.eql?('console')
59
+ end
60
+ end
61
+
62
+ def on_javascript_log(filter_by = nil, &block)
63
+ check_valid_filter(filter_by)
64
+
65
+ on_log do |params|
66
+ type = params['type']
67
+ javascript_log_events(params, filter_by, &block) if type.eql?('javascript')
68
+ end
69
+ end
70
+
71
+ def on_javascript_exception(&block)
72
+ on_log do |params|
73
+ type = params['type']
74
+ javascript_log_events(params, FilterBy.log_level('error'), &block) if type.eql?('javascript')
75
+ end
76
+ end
77
+
78
+ def on_log(filter_by = nil, &block)
79
+ unless filter_by.nil?
80
+ check_valid_filter(filter_by)
81
+
82
+ on(:entry_added) do |params|
83
+ yield(params) if params['level'] == filter_by.level
84
+ end
85
+ return
86
+ end
87
+
88
+ on(:entry_added, &block)
89
+ end
90
+
91
+ private
92
+
93
+ def on(event, &block)
94
+ event = EVENTS[event] if event.is_a?(Symbol)
95
+ @bidi.callbacks["log.#{event}"] << block
96
+ end
97
+
98
+ def check_valid_filter(filter_by)
99
+ return if filter_by.nil? || filter_by.instance_of?(FilterBy)
100
+
101
+ raise "Pass valid FilterBy object. Received: #{filter_by.inspect}"
102
+ end
103
+
104
+ def console_log_events(params, filter_by)
105
+ event = ConsoleLogEntry.new(
106
+ level: params['level'],
107
+ text: params['text'],
108
+ timestamp: params['timestamp'],
109
+ type: params['type'],
110
+ method: params['method'],
111
+ realm: params['realm'],
112
+ args: params['args'],
113
+ stack_trace: params['stackTrace']
114
+ )
115
+
116
+ unless filter_by.nil?
117
+ yield(event) if params['level'] == filter_by.level
118
+ return
119
+ end
120
+
121
+ yield(event)
122
+ end
123
+
124
+ def javascript_log_events(params, filter_by)
125
+ event = JavascriptLogEntry.new(
126
+ level: params['level'],
127
+ text: params['text'],
128
+ timestamp: params['timestamp'],
129
+ type: params['type'],
130
+ stack_trace: params['stackTrace']
131
+ )
132
+
133
+ unless filter_by.nil?
134
+ yield(event) if params['level'] == filter_by.level
135
+ return
136
+ end
137
+
138
+ yield(event)
139
+ end
140
+ end # LogInspector
141
+ end # Bidi
142
+ end # WebDriver
143
+ end # Selenium
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ class BiDi
23
+ class NavigateResult
24
+ attr_accessor :url, :navigation_id
25
+
26
+ def initialize(url:, navigation_id:)
27
+ @url = url
28
+ @navigation_id = navigation_id
29
+ end
30
+ end # NavigateResult
31
+ end # BiDi
32
+ end # WebDriver
33
+ end # Selenium
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ class BiDi
23
+ class Session
24
+ Status = Struct.new(:ready, :message)
25
+
26
+ def initialize(bidi)
27
+ @bidi = bidi
28
+ end
29
+
30
+ def status
31
+ status = @bidi.send_cmd('session.status')
32
+ Status.new(status['ready'], status['message'])
33
+ end
34
+
35
+ def subscribe(events, browsing_contexts = nil)
36
+ events_list = Array(events)
37
+ browsing_contexts_list = browsing_contexts.nil? ? nil : Array(browsing_contexts)
38
+
39
+ @bidi.send_cmd('session.subscribe', events: events_list, contexts: browsing_contexts_list)
40
+ end
41
+
42
+ def unsubscribe(events, browsing_contexts = nil)
43
+ events_list = Array(events)
44
+ browsing_contexts_list = browsing_contexts.nil? ? nil : Array(browsing_contexts)
45
+
46
+ @bidi.send_cmd('session.unsubscribe', events: events_list, contexts: browsing_contexts_list)
47
+ end
48
+ end # Session
49
+ end # BiDi
50
+ end # WebDriver
51
+ end # Selenium
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ class BiDi
23
+ autoload :Session, 'selenium/webdriver/bidi/session'
24
+ autoload :LogInspector, 'selenium/webdriver/bidi/log_inspector'
25
+ autoload :BrowsingContext, 'selenium/webdriver/bidi/browsing_context'
26
+
27
+ def initialize(url:)
28
+ @ws = WebSocketConnection.new(url: url)
29
+ end
30
+
31
+ def close
32
+ @ws.close
33
+ end
34
+
35
+ def callbacks
36
+ @ws.callbacks
37
+ end
38
+
39
+ def session
40
+ @session ||= Session.new(self)
41
+ end
42
+
43
+ def send_cmd(method, **params)
44
+ data = {method: method, params: params.compact}
45
+ message = @ws.send_cmd(**data)
46
+ raise Error::WebDriverError, error_message(message) if message['error']
47
+
48
+ message['result']
49
+ end
50
+
51
+ def error_message(message)
52
+ "#{message['error']}: #{message['message']}\n#{message['stacktrace']}"
53
+ end
54
+ end # BiDi
55
+ end # WebDriver
56
+ end # Selenium
@@ -17,31 +17,23 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
+ require 'selenium/webdriver/chromium/driver'
21
+
20
22
  module Selenium
21
23
  module WebDriver
22
24
  module Chrome
23
-
24
25
  #
25
26
  # Driver implementation for Chrome.
26
27
  # @api private
27
28
  #
28
29
 
29
- class Driver < WebDriver::Driver
30
- EXTENSIONS = [DriverExtensions::HasCDP,
31
- DriverExtensions::HasCasting,
32
- DriverExtensions::HasNetworkConditions,
33
- DriverExtensions::HasNetworkInterception,
34
- DriverExtensions::HasWebStorage,
35
- DriverExtensions::HasLaunching,
36
- DriverExtensions::HasLocation,
37
- DriverExtensions::HasPermissions,
38
- DriverExtensions::DownloadsFiles,
39
- DriverExtensions::HasDevTools,
40
- DriverExtensions::HasAuthentication,
41
- DriverExtensions::HasLogs,
42
- DriverExtensions::HasLogEvents,
43
- DriverExtensions::HasPinnedScripts,
44
- DriverExtensions::PrintsPage].freeze
30
+ class Driver < Chromium::Driver
31
+ include LocalDriver
32
+
33
+ def initialize(capabilities: nil, options: nil, service: nil, url: nil, **opts)
34
+ caps, url = initialize_local_driver(capabilities, options, service, url)
35
+ super(caps: caps, url: url, **opts)
36
+ end
45
37
 
46
38
  def browser
47
39
  :chrome
@@ -49,21 +41,9 @@ module Selenium
49
41
 
50
42
  private
51
43
 
52
- def devtools_url
53
- uri = URI(devtools_address)
54
- response = Net::HTTP.get(uri.hostname, '/json/version', uri.port)
55
-
56
- JSON.parse(response)['webSocketDebuggerUrl']
57
- end
58
-
59
- def devtools_version
60
- Integer(capabilities.browser_version.split('.').first)
61
- end
62
-
63
44
  def devtools_address
64
45
  "http://#{capabilities['goog:chromeOptions']['debuggerAddress']}"
65
46
  end
66
-
67
47
  end # Driver
68
48
  end # Chrome
69
49
  end # WebDriver
@@ -17,88 +17,26 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
+ require 'selenium/webdriver/chromium/features'
21
+
20
22
  module Selenium
21
23
  module WebDriver
22
24
  module Chrome
23
25
  module Features
26
+ include WebDriver::Chromium::Features
24
27
 
25
28
  CHROME_COMMANDS = {
26
- launch_app: [:post, 'session/:session_id/chromium/launch_app'],
27
29
  get_cast_sinks: [:get, 'session/:session_id/goog/cast/get_sinks'],
28
30
  set_cast_sink_to_use: [:post, 'session/:session_id/goog/cast/set_sink_to_use'],
29
31
  start_cast_tab_mirroring: [:post, 'session/:session_id/goog/cast/start_tab_mirroring'],
32
+ start_cast_desktop_mirroring: [:post, 'session/:session_id/goog/cast/start_desktop_mirroring'],
30
33
  get_cast_issue_message: [:get, 'session/:session_id/goog/cast/get_issue_message'],
31
34
  stop_casting: [:post, 'session/:session_id/goog/cast/stop_casting'],
32
- get_network_conditions: [:get, 'session/:session_id/chromium/network_conditions'],
33
- set_network_conditions: [:post, 'session/:session_id/chromium/network_conditions'],
34
- delete_network_conditions: [:delete, 'session/:session_id/chromium/network_conditions'],
35
- set_permission: [:post, 'session/:session_id/permissions'],
36
- send_command: [:post, 'session/:session_id/goog/cdp/execute'],
37
- get_available_log_types: [:get, 'session/:session_id/se/log/types'],
38
- get_log: [:post, 'session/:session_id/se/log']
35
+ send_command: [:post, 'session/:session_id/goog/cdp/execute']
39
36
  }.freeze
40
37
 
41
38
  def commands(command)
42
- CHROME_COMMANDS[command] || self.class::COMMANDS[command]
43
- end
44
-
45
- def launch_app(id)
46
- execute :launch_app, {}, {id: id}
47
- end
48
-
49
- def cast_sinks
50
- execute :get_cast_sinks
51
- end
52
-
53
- def cast_sink_to_use=(name)
54
- execute :set_cast_sink_to_use, {}, {sinkName: name}
55
- end
56
-
57
- def cast_issue_message
58
- execute :cast_issue_message
59
- end
60
-
61
- def start_cast_tab_mirroring(name)
62
- execute :start_cast_tab_mirroring, {}, {sinkName: name}
63
- end
64
-
65
- def stop_casting(name)
66
- execute :stop_casting, {}, {sinkName: name}
67
- end
68
-
69
- def set_permission(name, value)
70
- execute :set_permission, {}, {descriptor: {name: name}, state: value}
71
- end
72
-
73
- def network_conditions
74
- execute :get_network_conditions
75
- end
76
-
77
- def network_conditions=(conditions)
78
- execute :set_network_conditions, {}, {network_conditions: conditions}
79
- end
80
-
81
- def delete_network_conditions
82
- execute :delete_network_conditions
83
- end
84
-
85
- def send_command(command_params)
86
- execute :send_command, {}, command_params
87
- end
88
-
89
- def available_log_types
90
- types = execute :get_available_log_types
91
- Array(types).map(&:to_sym)
92
- end
93
-
94
- def log(type)
95
- data = execute :get_log, {}, {type: type.to_s}
96
-
97
- Array(data).map do |l|
98
- LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
99
- rescue KeyError
100
- next
101
- end
39
+ CHROME_COMMANDS[command] || CHROMIUM_COMMANDS[command] || self.class::COMMANDS[command]
102
40
  end
103
41
  end # Bridge
104
42
  end # Chrome