selenium-webdriver 4.0.0.alpha5 → 4.0.0.alpha6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +38 -0
  3. data/LICENSE +1 -1
  4. data/lib/selenium/webdriver/atoms/findElements.js +1 -1
  5. data/lib/selenium/webdriver/chrome/bridge.rb +4 -6
  6. data/lib/selenium/webdriver/chrome/driver.rb +4 -0
  7. data/lib/selenium/webdriver/chrome/options.rb +24 -19
  8. data/lib/selenium/webdriver/common.rb +1 -0
  9. data/lib/selenium/webdriver/common/driver.rb +55 -23
  10. data/lib/selenium/webdriver/common/logger.rb +1 -1
  11. data/lib/selenium/webdriver/common/manager.rb +5 -0
  12. data/lib/selenium/webdriver/common/options.rb +32 -9
  13. data/lib/selenium/webdriver/common/port_prober.rb +4 -6
  14. data/lib/selenium/webdriver/common/service.rb +12 -106
  15. data/lib/selenium/webdriver/common/service_manager.rb +151 -0
  16. data/lib/selenium/webdriver/devtools.rb +118 -0
  17. data/lib/selenium/webdriver/devtools/accessibility.rb +62 -0
  18. data/lib/selenium/webdriver/devtools/animation.rb +98 -0
  19. data/lib/selenium/webdriver/devtools/application_cache.rb +64 -0
  20. data/lib/selenium/webdriver/devtools/audits.rb +61 -0
  21. data/lib/selenium/webdriver/devtools/background_service.rb +67 -0
  22. data/lib/selenium/webdriver/devtools/browser.rb +123 -0
  23. data/lib/selenium/webdriver/devtools/cache_storage.rb +73 -0
  24. data/lib/selenium/webdriver/devtools/cast.rb +70 -0
  25. data/lib/selenium/webdriver/devtools/console.rb +57 -0
  26. data/lib/selenium/webdriver/devtools/css.rb +165 -0
  27. data/lib/selenium/webdriver/devtools/database.rb +64 -0
  28. data/lib/selenium/webdriver/devtools/debugger.rb +229 -0
  29. data/lib/selenium/webdriver/devtools/device_orientation.rb +53 -0
  30. data/lib/selenium/webdriver/devtools/dom.rb +320 -0
  31. data/lib/selenium/webdriver/devtools/domdebugger.rb +93 -0
  32. data/lib/selenium/webdriver/devtools/domsnapshot.rb +65 -0
  33. data/lib/selenium/webdriver/devtools/domstorage.rb +79 -0
  34. data/lib/selenium/webdriver/devtools/emulation.rb +180 -0
  35. data/lib/selenium/webdriver/devtools/fetch.rb +97 -0
  36. data/lib/selenium/webdriver/devtools/headless_experimental.rb +61 -0
  37. data/lib/selenium/webdriver/devtools/heap_profiler.rb +107 -0
  38. data/lib/selenium/webdriver/devtools/indexed_db.rb +100 -0
  39. data/lib/selenium/webdriver/devtools/input.rb +140 -0
  40. data/lib/selenium/webdriver/devtools/inspector.rb +55 -0
  41. data/lib/selenium/webdriver/devtools/io.rb +59 -0
  42. data/lib/selenium/webdriver/devtools/layer_tree.rb +95 -0
  43. data/lib/selenium/webdriver/devtools/log.rb +66 -0
  44. data/lib/selenium/webdriver/devtools/media.rb +57 -0
  45. data/lib/selenium/webdriver/devtools/memory.rb +86 -0
  46. data/lib/selenium/webdriver/devtools/network.rb +228 -0
  47. data/lib/selenium/webdriver/devtools/overlay.rb +157 -0
  48. data/lib/selenium/webdriver/devtools/page.rb +374 -0
  49. data/lib/selenium/webdriver/devtools/performance.rb +63 -0
  50. data/lib/selenium/webdriver/devtools/profiler.rb +111 -0
  51. data/lib/selenium/webdriver/devtools/runtime.rb +193 -0
  52. data/lib/selenium/webdriver/devtools/schema.rb +46 -0
  53. data/lib/selenium/webdriver/devtools/security.rb +71 -0
  54. data/lib/selenium/webdriver/devtools/service_worker.rb +116 -0
  55. data/lib/selenium/webdriver/devtools/storage.rb +95 -0
  56. data/lib/selenium/webdriver/devtools/system_info.rb +50 -0
  57. data/lib/selenium/webdriver/devtools/target.rb +141 -0
  58. data/lib/selenium/webdriver/devtools/tethering.rb +55 -0
  59. data/lib/selenium/webdriver/devtools/tracing.rb +76 -0
  60. data/lib/selenium/webdriver/devtools/web_audio.rb +70 -0
  61. data/lib/selenium/webdriver/devtools/web_authn.rb +94 -0
  62. data/lib/selenium/webdriver/edge_chrome/bridge.rb +9 -2
  63. data/lib/selenium/webdriver/edge_chrome/driver.rb +4 -0
  64. data/lib/selenium/webdriver/edge_chrome/options.rb +2 -0
  65. data/lib/selenium/webdriver/edge_html/options.rb +2 -9
  66. data/lib/selenium/webdriver/firefox/bridge.rb +1 -1
  67. data/lib/selenium/webdriver/firefox/driver.rb +4 -0
  68. data/lib/selenium/webdriver/firefox/options.rb +5 -10
  69. data/lib/selenium/webdriver/ie/options.rb +7 -10
  70. data/lib/selenium/webdriver/remote/bridge.rb +3 -13
  71. data/lib/selenium/webdriver/remote/capabilities.rb +11 -6
  72. data/lib/selenium/webdriver/safari/bridge.rb +1 -1
  73. data/lib/selenium/webdriver/safari/driver.rb +4 -0
  74. data/lib/selenium/webdriver/safari/options.rb +1 -8
  75. data/lib/selenium/webdriver/support/cdp_client_generator.rb +77 -0
  76. data/lib/selenium/webdriver/support/color.rb +2 -2
  77. data/lib/selenium/webdriver/version.rb +1 -1
  78. data/selenium-webdriver.gemspec +2 -2
  79. metadata +53 -5
@@ -0,0 +1,76 @@
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
+ module Selenium
22
+ module WebDriver
23
+ class DevTools
24
+ def tracing
25
+ @tracing ||= Tracing.new(self)
26
+ end
27
+
28
+ class Tracing
29
+ EVENTS = {
30
+ buffer_usage: 'bufferUsage',
31
+ data_collected: 'dataCollected',
32
+ tracing_complete: 'tracingComplete',
33
+ }
34
+
35
+ def initialize(devtools)
36
+ @devtools = devtools
37
+ end
38
+
39
+ def on(event, &block)
40
+ event = EVENTS[event] if event.is_a?(Symbol)
41
+ @devtools.callbacks["Tracing.#{event}"] << block
42
+ end
43
+
44
+ def _end
45
+ @devtools.send_cmd('Tracing.end')
46
+ end
47
+
48
+ def get_categories
49
+ @devtools.send_cmd('Tracing.getCategories')
50
+ end
51
+
52
+ def record_clock_sync_marker(sync_id:)
53
+ @devtools.send_cmd('Tracing.recordClockSyncMarker',
54
+ syncId: sync_id)
55
+ end
56
+
57
+ def request_memory_dump(deterministic: nil)
58
+ @devtools.send_cmd('Tracing.requestMemoryDump',
59
+ deterministic: deterministic)
60
+ end
61
+
62
+ def start(categories: nil, options: nil, buffer_usage_reporting_interval: nil, transfer_mode: nil, stream_format: nil, stream_compression: nil, trace_config: nil)
63
+ @devtools.send_cmd('Tracing.start',
64
+ categories: categories,
65
+ options: options,
66
+ bufferUsageReportingInterval: buffer_usage_reporting_interval,
67
+ transferMode: transfer_mode,
68
+ streamFormat: stream_format,
69
+ streamCompression: stream_compression,
70
+ traceConfig: trace_config)
71
+ end
72
+
73
+ end # Tracing
74
+ end # DevTools
75
+ end # WebDriver
76
+ end # Selenium
@@ -0,0 +1,70 @@
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
+ module Selenium
22
+ module WebDriver
23
+ class DevTools
24
+ def web_audio
25
+ @web_audio ||= WebAudio.new(self)
26
+ end
27
+
28
+ class WebAudio
29
+ EVENTS = {
30
+ context_created: 'contextCreated',
31
+ context_will_be_destroyed: 'contextWillBeDestroyed',
32
+ context_changed: 'contextChanged',
33
+ audio_listener_created: 'audioListenerCreated',
34
+ audio_listener_will_be_destroyed: 'audioListenerWillBeDestroyed',
35
+ audio_node_created: 'audioNodeCreated',
36
+ audio_node_will_be_destroyed: 'audioNodeWillBeDestroyed',
37
+ audio_param_created: 'audioParamCreated',
38
+ audio_param_will_be_destroyed: 'audioParamWillBeDestroyed',
39
+ nodes_connected: 'nodesConnected',
40
+ nodes_disconnected: 'nodesDisconnected',
41
+ node_param_connected: 'nodeParamConnected',
42
+ node_param_disconnected: 'nodeParamDisconnected',
43
+ }
44
+
45
+ def initialize(devtools)
46
+ @devtools = devtools
47
+ end
48
+
49
+ def on(event, &block)
50
+ event = EVENTS[event] if event.is_a?(Symbol)
51
+ @devtools.callbacks["WebAudio.#{event}"] << block
52
+ end
53
+
54
+ def enable
55
+ @devtools.send_cmd('WebAudio.enable')
56
+ end
57
+
58
+ def disable
59
+ @devtools.send_cmd('WebAudio.disable')
60
+ end
61
+
62
+ def get_realtime_data(context_id:)
63
+ @devtools.send_cmd('WebAudio.getRealtimeData',
64
+ contextId: context_id)
65
+ end
66
+
67
+ end # WebAudio
68
+ end # DevTools
69
+ end # WebDriver
70
+ end # Selenium
@@ -0,0 +1,94 @@
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
+ module Selenium
22
+ module WebDriver
23
+ class DevTools
24
+ def web_authn
25
+ @web_authn ||= WebAuthn.new(self)
26
+ end
27
+
28
+ class WebAuthn
29
+
30
+ def initialize(devtools)
31
+ @devtools = devtools
32
+ end
33
+
34
+ def on(event, &block)
35
+ event = EVENTS[event] if event.is_a?(Symbol)
36
+ @devtools.callbacks["WebAuthn.#{event}"] << block
37
+ end
38
+
39
+ def enable
40
+ @devtools.send_cmd('WebAuthn.enable')
41
+ end
42
+
43
+ def disable
44
+ @devtools.send_cmd('WebAuthn.disable')
45
+ end
46
+
47
+ def add_virtual_authenticator(options:)
48
+ @devtools.send_cmd('WebAuthn.addVirtualAuthenticator',
49
+ options: options)
50
+ end
51
+
52
+ def remove_virtual_authenticator(authenticator_id:)
53
+ @devtools.send_cmd('WebAuthn.removeVirtualAuthenticator',
54
+ authenticatorId: authenticator_id)
55
+ end
56
+
57
+ def add_credential(authenticator_id:, credential:)
58
+ @devtools.send_cmd('WebAuthn.addCredential',
59
+ authenticatorId: authenticator_id,
60
+ credential: credential)
61
+ end
62
+
63
+ def get_credential(authenticator_id:, credential_id:)
64
+ @devtools.send_cmd('WebAuthn.getCredential',
65
+ authenticatorId: authenticator_id,
66
+ credentialId: credential_id)
67
+ end
68
+
69
+ def get_credentials(authenticator_id:)
70
+ @devtools.send_cmd('WebAuthn.getCredentials',
71
+ authenticatorId: authenticator_id)
72
+ end
73
+
74
+ def remove_credential(authenticator_id:, credential_id:)
75
+ @devtools.send_cmd('WebAuthn.removeCredential',
76
+ authenticatorId: authenticator_id,
77
+ credentialId: credential_id)
78
+ end
79
+
80
+ def clear_credentials(authenticator_id:)
81
+ @devtools.send_cmd('WebAuthn.clearCredentials',
82
+ authenticatorId: authenticator_id)
83
+ end
84
+
85
+ def set_user_verified(authenticator_id:, is_user_verified:)
86
+ @devtools.send_cmd('WebAuthn.setUserVerified',
87
+ authenticatorId: authenticator_id,
88
+ isUserVerified: is_user_verified)
89
+ end
90
+
91
+ end # WebAuthn
92
+ end # DevTools
93
+ end # WebDriver
94
+ end # Selenium
@@ -22,8 +22,15 @@ require 'selenium/webdriver/chrome/bridge'
22
22
  module Selenium
23
23
  module WebDriver
24
24
  module EdgeChrome
25
- module Bridge
26
- include Selenium::WebDriver::Chrome::Bridge
25
+ class Bridge < WebDriver::Chrome::Bridge
26
+
27
+ COMMANDS = WebDriver::Chrome::Bridge::COMMANDS.merge(
28
+ send_command: [:post, 'session/:session_id/ms/cdp/execute']
29
+ ).freeze
30
+
31
+ def commands(command)
32
+ COMMANDS[command] || super
33
+ end
27
34
  end # Bridge
28
35
  end # EdgeChrome
29
36
  end # WebDriver
@@ -32,6 +32,10 @@ module Selenium
32
32
  def browser
33
33
  :edge_chrome
34
34
  end
35
+
36
+ def bridge_class
37
+ Bridge
38
+ end
35
39
  end # Driver
36
40
  end # EdgeChrome
37
41
  end # WebDriver
@@ -23,6 +23,8 @@ module Selenium
23
23
  module WebDriver
24
24
  module EdgeChrome
25
25
  class Options < Selenium::WebDriver::Chrome::Options
26
+ BROWSER = 'MSEdge'
27
+
26
28
  private
27
29
 
28
30
  def binary_path
@@ -25,6 +25,7 @@ module Selenium
25
25
  CAPABILITIES = {in_private: 'ms:inPrivate',
26
26
  extension_paths: 'ms:extensionPaths',
27
27
  start_page: 'ms:startPage'}.freeze
28
+ BROWSER = 'MicrosoftEdge'
28
29
 
29
30
  CAPABILITIES.each_key do |key|
30
31
  define_method key do
@@ -52,7 +53,7 @@ module Selenium
52
53
  #
53
54
 
54
55
  def initialize(**opts)
55
- super
56
+ super(**opts)
56
57
  @options[:extensions]&.each(&method(:validate_extension))
57
58
  end
58
59
 
@@ -72,14 +73,6 @@ module Selenium
72
73
  @options[:extension_paths] << path
73
74
  end
74
75
 
75
- #
76
- # @api private
77
- #
78
-
79
- def as_json(*)
80
- generate_as_json(super)
81
- end
82
-
83
76
  private
84
77
 
85
78
  def validate_extension(path)
@@ -20,7 +20,7 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Firefox
23
- module Bridge
23
+ class Bridge < WebDriver::Remote::Bridge
24
24
 
25
25
  COMMANDS = {
26
26
  install_addon: [:post, 'session/:session_id/moz/addon/install'],
@@ -34,6 +34,10 @@ module Selenium
34
34
  def browser
35
35
  :firefox
36
36
  end
37
+
38
+ def bridge_class
39
+ Bridge
40
+ end
37
41
  end # Driver
38
42
  end # Firefox
39
43
  end # WebDriver
@@ -29,6 +29,7 @@ module Selenium
29
29
  profile: 'profile',
30
30
  log: 'log',
31
31
  prefs: 'prefs'}.freeze
32
+ BROWSER = 'firefox'
32
33
 
33
34
  CAPABILITIES.each_key do |key|
34
35
  define_method key do
@@ -57,7 +58,7 @@ module Selenium
57
58
  #
58
59
 
59
60
  def initialize(log_level: nil, **opts)
60
- super(opts)
61
+ super(**opts)
61
62
 
62
63
  @options[:log] ||= {level: log_level} if log_level
63
64
  process_profile(@options[:profile]) if @options.key?(:profile)
@@ -134,19 +135,13 @@ module Selenium
134
135
  @options[:log] = {level: level}
135
136
  end
136
137
 
137
- #
138
- # @api private
139
- #
138
+ private
140
139
 
141
- def as_json(*)
142
- options = super
140
+ def process_browser_options(browser_options)
141
+ options = browser_options[KEY]
143
142
  options['binary'] ||= Firefox.path if Firefox.path
144
-
145
- {KEY => generate_as_json(options)}
146
143
  end
147
144
 
148
- private
149
-
150
145
  def process_profile(profile)
151
146
  @options[:profile] = if profile.nil?
152
147
  nil
@@ -41,6 +41,7 @@ module Selenium
41
41
  use_per_process_proxy: 'ie.usePerProcessProxy',
42
42
  validate_cookie_document_type: 'ie.validateCookieDocumentType'
43
43
  }.freeze
44
+ BROWSER = 'internet_explorer'
44
45
 
45
46
  CAPABILITIES.each_key do |key|
46
47
  define_method key do
@@ -85,10 +86,10 @@ module Selenium
85
86
  # @option opts [Boolean] validate_cookie_document_type
86
87
  #
87
88
 
88
- def initialize(args: nil, **opts)
89
- super(opts)
89
+ def initialize(**opts)
90
+ @args = (opts.delete(:args) || []).to_set
91
+ super(**opts)
90
92
 
91
- @args = (args || []).to_set
92
93
  @options[:native_events] = true if @options[:native_events].nil?
93
94
  end
94
95
 
@@ -102,15 +103,11 @@ module Selenium
102
103
  @args << arg
103
104
  end
104
105
 
105
- #
106
- # @api private
107
- #
106
+ private
108
107
 
109
- def as_json(*)
110
- options = super
108
+ def process_browser_options(browser_options)
109
+ options = browser_options[KEY]
111
110
  options['ie.browserCommandLineSwitches'] = @args.to_a.join(' ') if @args.any?
112
-
113
- {KEY => generate_as_json(options)}
114
111
  end
115
112
  end # Options
116
113
  end # IE
@@ -37,7 +37,7 @@ module Selenium
37
37
 
38
38
  def initialize(http_client: nil, url:)
39
39
  uri = url.is_a?(URI) ? url : URI.parse(url)
40
- uri.path += '/' unless %r{\/$}.match?(uri.path)
40
+ uri.path += '/' unless uri.path.end_with?('/')
41
41
 
42
42
  @http = http_client || Http::Default.new
43
43
  @http.server_url = uri
@@ -48,8 +48,8 @@ module Selenium
48
48
  # Creates session.
49
49
  #
50
50
 
51
- def create_session(desired_capabilities, options = nil)
52
- response = execute(:new_session, {}, merged_capabilities(desired_capabilities, options))
51
+ def create_session(capabilities)
52
+ response = execute(:new_session, {}, {capabilities: {firstMatch: [capabilities]}})
53
53
 
54
54
  @session_id = response['sessionId']
55
55
  capabilities = response['capabilities']
@@ -571,16 +571,6 @@ module Selenium
571
571
  COMMANDS[command]
572
572
  end
573
573
 
574
- def merged_capabilities(capabilities, options = nil)
575
- capabilities.merge!(options.as_json) if options
576
-
577
- {
578
- capabilities: {
579
- firstMatch: [capabilities]
580
- }
581
- }
582
- end
583
-
584
574
  def unwrap_script_result(arg)
585
575
  case arg
586
576
  when Array