selenium-webdriver 4.6.1 → 4.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e5a3a63437323859cfcd9e2c2de24eb03db07baf71783ce64b720ea50b51517
4
- data.tar.gz: ac97d032d52743c7a514dfd027d54696361ee9a98253600de092e3eb9c374b0a
3
+ metadata.gz: 0e30bfb529c5499329e02fe9a1e511b5bf0d358444f66a2afd45e98783e6b3d1
4
+ data.tar.gz: 10b0e20b9ad667fe4b872c7721926009065af0807da3f156f99d76ca42531e5b
5
5
  SHA512:
6
- metadata.gz: b5959ce29798e1fed97317ed4839e2e520100f299451589ec5833a36e0d445a53b9d6deba43f99ba132d5f366c3dd9de6b481f6efde97e04bfd07f088895f2c8
7
- data.tar.gz: 280a4a659cf212b04a6426acad25b701a9c4a8a34ac9a43fbe368fade7f05092da377fbdbb1d95a65787021ac2074ec7b826a3d1abd072576be48fabd574a2b3
6
+ metadata.gz: 967e493c8a785e817e9a117da8d642d1b9529ad13fa7be53dc7b3305cae9bf7031fc5497c84a0aeb9551aa8bf0d5325479362f8180c7e683c6a6a4e06fbb7b2f
7
+ data.tar.gz: a5d37e0f131b8004141b91c1b3a70412c16a65c7615bae1fee3f5a112bce45471211fe2507a356c1bcd8f01c43b49a44f3da31430fd01f0f964aaaf3ca757d9d
data/CHANGES CHANGED
@@ -1,3 +1,17 @@
1
+ 4.7.0 (2022-12-01)
2
+ =========================
3
+ BiDi:
4
+ * Released selenium-devtools 0.108.0 (supports CDP v85, v106, v107, v108)
5
+ * Fix bug with socket stability
6
+
7
+ Ruby:
8
+ * Remove dependency on ChildProcess gem in favor of native Process.spawn (#11251)
9
+ * Add support for Selenium Manager to work with IE Driver
10
+ * Improve error handling for Selenium Manager
11
+
12
+ Safari:
13
+ * Fix bug preventing Safari Options from being used with Safari Technology Preview
14
+
1
15
  4.6.1 (2022-11-04)
2
16
  =========================
3
17
  Ruby:
@@ -15,7 +29,6 @@ Ruby:
15
29
  * Make sure selenium-manager is packed into gem
16
30
  * Fix platform list in #scroll_by guard
17
31
 
18
-
19
32
  4.5.0 (2022-09-28)
20
33
  =========================
21
34
 
Binary file
Binary file
Binary file
@@ -17,7 +17,7 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- require 'childprocess'
20
+ require 'selenium/webdriver/common/child_process'
21
21
  require 'selenium/webdriver/common/socket_poller'
22
22
  require 'net/http'
23
23
 
@@ -237,7 +237,7 @@ module Selenium
237
237
 
238
238
  begin
239
239
  @process.poll_for_exit(5)
240
- rescue ChildProcess::TimeoutError
240
+ rescue WebDriver::ChildProcess::TimeoutError
241
241
  @process.stop
242
242
  end
243
243
  rescue Errno::ECHILD
@@ -252,16 +252,13 @@ module Selenium
252
252
  properties = @additional_args.dup - @additional_args.delete_if { |arg| arg[/^-D/] }
253
253
  args = ['-jar', @jar, @role, '--port', @port.to_s]
254
254
  server_command = ['java'] + properties + args + @additional_args
255
- cp = ChildProcess.build(*server_command)
255
+ cp = WebDriver::ChildProcess.build(*server_command)
256
256
  WebDriver.logger.debug("Executing Process #{server_command}")
257
257
 
258
- io = cp.io
259
-
260
258
  if @log.is_a?(String)
261
- @log_file = File.open(@log, 'w')
262
- io.stdout = io.stderr = @log_file
259
+ cp.io = @log
263
260
  elsif @log
264
- io.inherit!
261
+ cp.io = :out
265
262
  end
266
263
 
267
264
  cp.detach = @background
File without changes
File without changes
File without changes
@@ -0,0 +1,126 @@
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
+
23
+ #
24
+ # @api private
25
+ #
26
+
27
+ class ChildProcess
28
+ TimeoutError = Class.new(StandardError)
29
+
30
+ SIGTERM = 'TERM'
31
+ SIGKILL = 'KILL'
32
+
33
+ POLL_INTERVAL = 0.1
34
+
35
+ attr_accessor :detach
36
+ attr_writer :io
37
+
38
+ def self.build(*command)
39
+ new(*command)
40
+ end
41
+
42
+ def initialize(*command)
43
+ @command = command
44
+ @detach = false
45
+ @pid = nil
46
+ @status = nil
47
+ end
48
+
49
+ def io
50
+ @io ||= Platform.null_device
51
+ end
52
+
53
+ def start
54
+ options = {%i[out err] => io}
55
+ options[:pgroup] = true unless Platform.windows? # NOTE: this is a bug only in Windows 7
56
+
57
+ WebDriver.logger.debug("Starting process: #{@command} with #{options}")
58
+ @pid = Process.spawn(*@command, options)
59
+ WebDriver.logger.debug(" -> pid: #{@pid}")
60
+
61
+ Process.detach(@pid) if detach
62
+ end
63
+
64
+ def stop(timeout = 3)
65
+ return unless @pid
66
+ return if exited?
67
+
68
+ WebDriver.logger.debug("Sending TERM to process: #{@pid}")
69
+ terminate(@pid)
70
+ poll_for_exit(timeout)
71
+
72
+ WebDriver.logger.debug(" -> stopped #{@pid}")
73
+ rescue TimeoutError, Errno::EINVAL
74
+ WebDriver.logger.debug(" -> sending KILL to process: #{@pid}")
75
+ kill(@pid)
76
+ wait
77
+ WebDriver.logger.debug(" -> killed #{@pid}")
78
+ end
79
+
80
+ def alive?
81
+ @pid && !exited?
82
+ end
83
+
84
+ def exited?
85
+ return unless @pid
86
+
87
+ WebDriver.logger.debug("Checking if #{@pid} is exited:")
88
+ _, @status = Process.waitpid2(@pid, Process::WNOHANG | Process::WUNTRACED) if @status.nil?
89
+ return if @status.nil?
90
+
91
+ exit_code = @status.exitstatus || @status.termsig
92
+ WebDriver.logger.debug(" -> exit code is #{exit_code.inspect}")
93
+
94
+ !!exit_code
95
+ end
96
+
97
+ def poll_for_exit(timeout)
98
+ WebDriver.logger.debug("Polling #{timeout} seconds for exit of #{@pid}")
99
+
100
+ end_time = Time.now + timeout
101
+ sleep POLL_INTERVAL until exited? || Time.now > end_time
102
+
103
+ raise TimeoutError, " -> #{@pid} still alive after #{timeout} seconds" unless exited?
104
+ end
105
+
106
+ def wait
107
+ return if exited?
108
+
109
+ _, @status = Process.waitpid2(@pid)
110
+ end
111
+
112
+ private
113
+
114
+ def terminate(pid)
115
+ Process.kill(SIGTERM, pid)
116
+ end
117
+
118
+ def kill(pid)
119
+ Process.kill(SIGKILL, pid)
120
+ rescue Errno::ECHILD, Errno::ESRCH
121
+ # already dead
122
+ end
123
+
124
+ end # ChildProcess
125
+ end # WebDriver
126
+ end # Selenium
@@ -78,6 +78,10 @@ module Selenium
78
78
  engine == :jruby
79
79
  end
80
80
 
81
+ def truffleruby?
82
+ engine == :truffleruby
83
+ end
84
+
81
85
  def ruby_version
82
86
  RUBY_VERSION
83
87
  end
@@ -17,6 +17,8 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
+ require 'open3'
21
+
20
22
  module Selenium
21
23
  module WebDriver
22
24
  #
@@ -32,12 +34,12 @@ module Selenium
32
34
  # @return [String] the path to the correct driver.
33
35
  def driver_path(driver_name)
34
36
  @driver_path ||= begin
35
- unless %w[chromedriver geckodriver msedgedriver].include?(driver_name)
37
+ unless %w[chromedriver geckodriver msedgedriver IEDriverServer.exe].include?(driver_name)
36
38
  msg = "Unable to locate driver with name: #{driver_name}"
37
39
  raise Error::WebDriverError, msg
38
40
  end
39
41
 
40
- location = run("#{binary} --driver #{driver_name}").split("\t").last.strip
42
+ location = run("#{binary} --driver #{driver_name}")
41
43
  WebDriver.logger.debug("Driver found at #{location}")
42
44
  Platform.assert_executable location
43
45
 
@@ -72,13 +74,16 @@ module Selenium
72
74
  WebDriver.logger.debug("Executing Process #{command}")
73
75
 
74
76
  begin
75
- result = `#{command}`
76
- return result if result.match?(/^INFO\t/)
77
+ stdout, stderr, status = Open3.capture3(command)
77
78
  rescue StandardError => e
78
- raise Error::WebDriverError, "Unsuccessful command executed: #{command}; #{e.message}"
79
+ raise Error::WebDriverError, "Unsuccessful command executed: #{command}", e.message
80
+ end
81
+
82
+ if status.exitstatus.positive?
83
+ raise Error::WebDriverError, "Unsuccessful command executed: #{command}\n#{stdout}#{stderr}"
79
84
  end
80
85
 
81
- raise Error::WebDriverError, "Unsuccessful command executed: #{command}"
86
+ stdout.gsub("INFO\t", '').strip
82
87
  end
83
88
  end
84
89
  end # SeleniumManager
@@ -102,7 +102,7 @@ module Selenium
102
102
  begin
103
103
  path ||= SeleniumManager.driver_path(self.class::EXECUTABLE)
104
104
  rescue Error::WebDriverError => e
105
- WebDriver.logger.debug("Unable obtain driver using Selenium Manager; #{e.message}")
105
+ WebDriver.logger.debug("Unable obtain driver using Selenium Manager\n #{e.message}")
106
106
  end
107
107
 
108
108
  raise Error::WebDriverError, self.class::MISSING_TEXT unless path
@@ -79,12 +79,7 @@ module Selenium
79
79
  def build_process(*command)
80
80
  WebDriver.logger.debug("Executing Process #{command}")
81
81
  @process = ChildProcess.build(*command)
82
- if WebDriver.logger.debug?
83
- @process.io.stdout = @process.io.stderr = WebDriver.logger.io
84
- elsif Platform.jruby?
85
- # Apparently we need to read the output of drivers on JRuby.
86
- @process.io.stdout = @process.io.stderr = File.new(Platform.null_device, 'w')
87
- end
82
+ @process.io = WebDriver.logger.io if WebDriver.logger.debug?
88
83
 
89
84
  @process
90
85
  end
@@ -104,8 +99,6 @@ module Selenium
104
99
 
105
100
  def start_process
106
101
  @process = build_process(@executable_path, "--port=#{@port}", *@extra_args)
107
- # NOTE: this is a bug only in Windows 7
108
- @process.leader = true unless Platform.windows?
109
102
  @process.start
110
103
  end
111
104
 
@@ -113,7 +106,6 @@ module Selenium
113
106
  return if process_exited?
114
107
 
115
108
  @process.stop STOP_TIMEOUT
116
- @process.io.stdout.close if Platform.jruby? && !WebDriver.logger.debug?
117
109
  end
118
110
 
119
111
  def stop_server
@@ -66,8 +66,7 @@ module Selenium
66
66
 
67
67
  def can_lock?
68
68
  @server = TCPServer.new(Platform.localhost, @port)
69
- ChildProcess.close_on_exec @server
70
-
69
+ @server.close_on_exec = true
71
70
  true
72
71
  rescue SocketError, Errno::EADDRINUSE, Errno::EBADF => e
73
72
  WebDriver.logger.debug("#{self}: #{e.message}")
@@ -22,6 +22,11 @@ require 'websocket'
22
22
  module Selenium
23
23
  module WebDriver
24
24
  class WebSocketConnection
25
+ CONNECTION_ERRORS = [
26
+ Errno::ECONNRESET, # connection is aborted (browser process was killed)
27
+ Errno::EPIPE # broken pipe (browser process was killed)
28
+ ].freeze
29
+
25
30
  RESPONSE_WAIT_TIMEOUT = 30
26
31
  RESPONSE_WAIT_INTERVAL = 0.1
27
32
 
@@ -90,6 +95,8 @@ module Selenium
90
95
  end
91
96
  end
92
97
  end
98
+ rescue *CONNECTION_ERRORS
99
+ Thread.stop
93
100
  end
94
101
  end
95
102
 
@@ -122,6 +129,8 @@ module Selenium
122
129
  Thread.current.report_on_exception = true
123
130
 
124
131
  yield params
132
+ rescue *CONNECTION_ERRORS
133
+ Thread.stop
125
134
  end
126
135
  end
127
136
 
@@ -96,3 +96,4 @@ require 'selenium/webdriver/common/driver'
96
96
  require 'selenium/webdriver/common/element'
97
97
  require 'selenium/webdriver/common/shadow_root'
98
98
  require 'selenium/webdriver/common/websocket_connection'
99
+ require 'selenium/webdriver/common/child_process'
File without changes
File without changes
File without changes
@@ -26,7 +26,7 @@ module Selenium
26
26
  # @see https://developer.apple.com/documentation/webkit/about_webdriver_for_safari
27
27
  CAPABILITIES = {automatic_inspection: 'safari:automaticInspection',
28
28
  automatic_profiling: 'safari:automaticProfiling'}.freeze
29
- BROWSER = 'safari'
29
+ BROWSER = Selenium::WebDriver::Safari.technology_preview? ? "Safari Technology Preview" : 'safari'
30
30
 
31
31
  def add_option(name, value = nil)
32
32
  key = name.is_a?(Hash) ? name.keys.first : name
@@ -0,0 +1,60 @@
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
+ require 'date'
21
+
22
+ module Selenium
23
+ module WebDriver
24
+ module Support
25
+
26
+ #
27
+ # Updates version in `version.rb` file with nightly suffix:
28
+ # - VERSION = '4.6.1'
29
+ # + VERSION = '4.6.1.nightly.20221126'
30
+ #
31
+ # @api private
32
+ #
33
+
34
+ class NightlyVersionGenerator
35
+
36
+ REGEXP = /VERSION = ['"]([\d.]+)['"]/.freeze
37
+
38
+ def self.call(version_file, version_suffix)
39
+ version_suffix ||= Date.today.strftime('%Y%m%d')
40
+ version_file_contents = File.read(version_file)
41
+ version_file_contents.gsub!(REGEXP) do
42
+ old_version = Regexp.last_match(1)
43
+ new_version = [old_version, 'nightly', version_suffix].join('.')
44
+ puts("#{old_version} -> #{new_version}")
45
+
46
+ "VERSION = '#{new_version}'"
47
+ end
48
+
49
+ File.write(version_file, version_file_contents)
50
+ end
51
+
52
+ end # NightlyVersionGenerator
53
+ end # Support
54
+ end # WebDriver
55
+ end # Selenium
56
+
57
+ if __FILE__ == $PROGRAM_NAME
58
+ version_file, version_suffix = *ARGV
59
+ Selenium::WebDriver::Support::NightlyVersionGenerator.call(version_file, version_suffix)
60
+ end
@@ -86,7 +86,7 @@ module Selenium
86
86
  #
87
87
  # <option value="foo">Bar</option>
88
88
  #
89
- # When slecting by :value, selects all options that have a value matching the argument. That is, when given "foo" this
89
+ # When selecting by :value, selects all options that have a value matching the argument. That is, when given "foo" this
90
90
  # would select an option like:
91
91
  #
92
92
  # <option value="foo">Bar</option>
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
- VERSION = '4.6.1'
22
+ VERSION = '4.7.0'
23
23
  end # WebDriver
24
24
  end # Selenium
@@ -17,7 +17,6 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- require 'childprocess'
21
20
  require 'tmpdir'
22
21
  require 'fileutils'
23
22
  require 'date'
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.homepage = 'https://selenium.dev'
25
25
  s.metadata = {
26
26
  'changelog_uri' => 'https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES',
27
+ 'github_repo' => 'ssh://github.com/SeleniumHQ/selenium',
27
28
  'source_code_uri' => 'https://github.com/SeleniumHQ/selenium/tree/trunk/rb',
28
29
  'rubygems_mfa_required' => 'true'
29
30
  }
@@ -48,13 +49,10 @@ Gem::Specification.new do |s|
48
49
  s.bindir = 'bin'
49
50
  s.require_paths = ['lib']
50
51
 
51
- s.add_runtime_dependency 'childprocess', ['>= 0.5', '< 5.0']
52
52
  s.add_runtime_dependency 'rexml', ['~> 3.2', '>= 3.2.5']
53
53
  s.add_runtime_dependency 'rubyzip', ['>= 1.2.2', '< 3.0']
54
54
  s.add_runtime_dependency 'websocket', ['~> 1.0']
55
55
 
56
- # childprocess requires ffi on windows but doesn't declare it in its dependencies
57
- s.add_development_dependency 'ffi'
58
56
  s.add_development_dependency 'pry', ['~> 0.14']
59
57
  s.add_development_dependency 'rack', ['~> 2.0']
60
58
  s.add_development_dependency 'rake'
metadata CHANGED
@@ -1,37 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.1
4
+ version: 4.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Rodionov
8
8
  - Titus Fortner
9
9
  - Thomas Walpole
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-11-04 00:00:00.000000000 Z
13
+ date: 2022-12-01 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: childprocess
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ">="
20
- - !ruby/object:Gem::Version
21
- version: '0.5'
22
- - - "<"
23
- - !ruby/object:Gem::Version
24
- version: '5.0'
25
- type: :runtime
26
- prerelease: false
27
- version_requirements: !ruby/object:Gem::Requirement
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- version: '0.5'
32
- - - "<"
33
- - !ruby/object:Gem::Version
34
- version: '5.0'
35
15
  - !ruby/object:Gem::Dependency
36
16
  name: rexml
37
17
  requirement: !ruby/object:Gem::Requirement
@@ -86,20 +66,6 @@ dependencies:
86
66
  - - "~>"
87
67
  - !ruby/object:Gem::Version
88
68
  version: '1.0'
89
- - !ruby/object:Gem::Dependency
90
- name: ffi
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
69
  - !ruby/object:Gem::Dependency
104
70
  name: pry
105
71
  requirement: !ruby/object:Gem::Requirement
@@ -293,6 +259,7 @@ files:
293
259
  - lib/selenium/webdriver/common.rb
294
260
  - lib/selenium/webdriver/common/action_builder.rb
295
261
  - lib/selenium/webdriver/common/alert.rb
262
+ - lib/selenium/webdriver/common/child_process.rb
296
263
  - lib/selenium/webdriver/common/driver.rb
297
264
  - lib/selenium/webdriver/common/driver_extensions/downloads_files.rb
298
265
  - lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb
@@ -415,7 +382,6 @@ files:
415
382
  - lib/selenium/webdriver/support.rb
416
383
  - lib/selenium/webdriver/support/abstract_event_listener.rb
417
384
  - lib/selenium/webdriver/support/block_event_listener.rb
418
- - lib/selenium/webdriver/support/cdp/domain.rb.erb
419
385
  - lib/selenium/webdriver/support/cdp_client_generator.rb
420
386
  - lib/selenium/webdriver/support/color.rb
421
387
  - lib/selenium/webdriver/support/escaper.rb
@@ -423,6 +389,7 @@ files:
423
389
  - lib/selenium/webdriver/support/guards.rb
424
390
  - lib/selenium/webdriver/support/guards/guard.rb
425
391
  - lib/selenium/webdriver/support/guards/guard_condition.rb
392
+ - lib/selenium/webdriver/support/nightly_version_generator.rb
426
393
  - lib/selenium/webdriver/support/relative_locator.rb
427
394
  - lib/selenium/webdriver/support/select.rb
428
395
  - lib/selenium/webdriver/version.rb
@@ -432,9 +399,10 @@ licenses:
432
399
  - Apache-2.0
433
400
  metadata:
434
401
  changelog_uri: https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES
402
+ github_repo: ssh://github.com/SeleniumHQ/selenium
435
403
  source_code_uri: https://github.com/SeleniumHQ/selenium/tree/trunk/rb
436
404
  rubygems_mfa_required: 'true'
437
- post_install_message:
405
+ post_install_message:
438
406
  rdoc_options: []
439
407
  require_paths:
440
408
  - lib
@@ -449,8 +417,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
449
417
  - !ruby/object:Gem::Version
450
418
  version: 1.3.1
451
419
  requirements: []
452
- rubygems_version: 3.0.3
453
- signing_key:
420
+ rubygems_version: 3.1.6
421
+ signing_key:
454
422
  specification_version: 4
455
423
  summary: Selenium is a browser automation tool for automated testing of webapps and
456
424
  more
@@ -1,63 +0,0 @@
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 DevTools
23
- module <%= version %>
24
- class <%= domain[:domain] %>
25
- <% if domain[:events] %>
26
- EVENTS = {
27
- <% domain[:events].each do |event| %>
28
- <%= h.snake_case(event[:name]) %>: '<%= event[:name] %>',
29
- <% end %>
30
- }.freeze
31
- <% end %>
32
-
33
- def initialize(devtools)
34
- @devtools = devtools
35
- end
36
-
37
- def on(event, &block)
38
- event = EVENTS[event] if event.is_a?(Symbol)
39
- @devtools.callbacks["<%= domain[:domain] %>.#{event}"] << block
40
- end
41
-
42
- <% domain[:commands].each do |command| %>
43
- <% if command[:parameters] %>
44
- def <%= h.snake_case(command[:name]) %>(<%= h.kwargs(command[:parameters]) %>)
45
- <% else %>
46
- def <%= h.snake_case(command[:name]) %>
47
- <% end %>
48
- <% if command[:parameters] %>
49
- @devtools.send_cmd('<%= domain[:domain] %>.<%= command[:name] %>',
50
- <% until command[:parameters].empty? %>
51
- <% parameter = command[:parameters].shift %>
52
- <%= parameter[:name] %>: <%= h.snake_case(parameter[:name]) %><%= command[:parameters].empty? ? ')' : ',' %>
53
- <% end %>
54
- <% else %>
55
- @devtools.send_cmd('<%= domain[:domain] %>.<%= command[:name] %>')
56
- <% end %>
57
- end
58
-
59
- <% end %>
60
- end # <%= domain[:domain] %>
61
- end # <%= version %>
62
- end # DevTools
63
- end # Selenium