selenium-webdriver 4.31.0 → 4.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 306139ef10e16f70cf3a8b0514c352d66a72d2a9a5a9ab55163ebce457b31519
4
- data.tar.gz: db1efc1750fffe9d5dc11e6740c9e27f7c63fb6a268f10f35071ba6629d3dc17
3
+ metadata.gz: 56908e35bba32bb626cb3ba219575445bfd885b65bedc8941f904e1eb146dd46
4
+ data.tar.gz: 0475666222e612f328cd32b5a76103c9429fafca5a22b037645a0c29878305f4
5
5
  SHA512:
6
- metadata.gz: 9e1af03b2cc953b0bf3fc89e651440f2586f307ecd7b971623a86f3ae19f7a24e26e330cd46bc767af93dd00e9a9654968eefb07d0ee22fbe855f40a8012fd85
7
- data.tar.gz: 11de4e8e2e1a5003dc8dc89625c5621afba8666ec9deea7e283931dfb9cdf6be1745b8b00701c1428b1210e7847e07405abd97e44d1673a21ba837091b1659b9
6
+ metadata.gz: 9c593f54082afe816d0a636c582bb5c22373ac05657b1defdf155e9966bd8772a6c3ab435aae0dbc02ebff15eb7b42d17dca6f1679903c32636d8915c0b35b47
7
+ data.tar.gz: c19562b66783e92fef359e286c44aa630e6783d374eecee6c0200d625830280149f291894d721ceed972f79401c13b8d533154955a27c13f7dc4604ceb7557de
data/CHANGES CHANGED
@@ -1,3 +1,15 @@
1
+ 4.32.0 (2025-05-02)
2
+ =========================
3
+ * Add CDP for Chrome 136 and remove 133
4
+ * log at info level with names and values when Guards#add_condition used
5
+ * Add PrintOptions Implementation for Ruby WebDriver (#15158)
6
+ * [ruby] fix lint for print_options.rb (#15608)
7
+ * add enable_downloads to attr_accessor for all options classes
8
+ * make logging of test guards debug level not info
9
+ * Set remote active protocol in Firefox to BiDi only
10
+ * handle issue with selenium manager exit status being nil (#15676)
11
+ * Add websocket-port parameter to firefox service (#15458)
12
+
1
13
  4.31.0 (2025-04-04)
2
14
  =========================
3
15
  * Add support for 135 and remove 132
Binary file
Binary file
Binary file
@@ -52,7 +52,7 @@ module Selenium
52
52
  end
53
53
 
54
54
  def set_capabilities
55
- (W3C_OPTIONS + self::CAPABILITIES.keys).each do |key|
55
+ (W3C_OPTIONS + GRID_OPTIONS + self::CAPABILITIES.keys).each do |key|
56
56
  next if method_defined? key
57
57
 
58
58
  define_method key do
@@ -0,0 +1,93 @@
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
+ # Represents options for printing a page.
23
+ class PrintOptions
24
+ DEFAULT_SCALE = 1.0
25
+ DEFAULT_ORIENTATION = 'portrait'
26
+ DEFAULT_PAGE_SIZE = {width: 21.0, height: 29.7}.freeze # A4 size in cm
27
+ DEFAULT_MARGINS = {top: 1.0, bottom: 1.0, left: 1.0, right: 1.0}.freeze
28
+
29
+ attr_accessor :orientation, :scale, :background, :page_ranges, :margins
30
+
31
+ def initialize
32
+ @orientation = DEFAULT_ORIENTATION
33
+ @scale = DEFAULT_SCALE
34
+ @background = false
35
+ @page_ranges = nil
36
+ @page_size = DEFAULT_PAGE_SIZE
37
+ @margins = DEFAULT_MARGINS
38
+ end
39
+
40
+ # Converts the options to a hash format to be used by WebDriver.
41
+ #
42
+ # @return [Hash]
43
+ def to_h
44
+ options = {
45
+ orientation: @orientation,
46
+ scale: @scale,
47
+ background: @background,
48
+ pageRanges: @page_ranges,
49
+ paperWidth: @page_size[:width],
50
+ paperHeight: @page_size[:height],
51
+ marginTop: @margins[:top],
52
+ marginBottom: @margins[:bottom],
53
+ marginLeft: @margins[:left],
54
+ marginRight: @margins[:right]
55
+ }
56
+
57
+ options.compact
58
+ end
59
+
60
+ # Gets the current page size.
61
+ #
62
+ # @return [Hash] The current page size hash with :width and :height.
63
+ attr_reader :page_size
64
+
65
+ # Sets the page size. Can be a predefined symbol or custom size hash.
66
+ #
67
+ # @param [Symbol, Hash] value The predefined size (:letter, :legal, :a4, :tabloid) or a custom hash.
68
+ def page_size=(value)
69
+ predefined_sizes = {
70
+ letter: {width: 21.59, height: 27.94},
71
+ legal: {width: 21.59, height: 35.56},
72
+ a4: {width: 21.0, height: 29.7},
73
+ tabloid: {width: 27.94, height: 43.18}
74
+ }
75
+
76
+ case value
77
+ when Symbol
78
+ raise ArgumentError, "Invalid page size: #{value}" unless predefined_sizes.key?(value)
79
+
80
+ @page_size = predefined_sizes[value]
81
+ when Hash
82
+ unless value.key?(:width) && value.key?(:height)
83
+ raise ArgumentError, 'Custom page size must include :width and :height'
84
+ end
85
+
86
+ @page_size = value
87
+ else
88
+ raise ArgumentError, 'Page size must be a Symbol or a Hash'
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -61,25 +61,12 @@ module Selenium
61
61
  end
62
62
 
63
63
  def run(*command)
64
- WebDriver.logger.debug("Executing Process #{command}", id: :selenium_manager)
65
-
66
- begin
67
- stdout, stderr, status = Open3.capture3(*command)
68
- rescue StandardError => e
69
- raise Error::WebDriverError, "Unsuccessful command executed: #{command}; #{e.message}"
70
- end
64
+ stdout, stderr, status = execute_command(*command)
65
+ result = parse_result_and_log(stdout)
71
66
 
72
- json_output = stdout.empty? ? {'logs' => [], 'result' => {}} : JSON.parse(stdout)
73
- json_output['logs'].each do |log|
74
- level = log['level'].casecmp('info').zero? ? 'debug' : log['level'].downcase
75
- WebDriver.logger.send(level, log['message'], id: :selenium_manager)
76
- end
67
+ validate_command_result(command, status, result, stderr)
77
68
 
78
- result = json_output['result']
79
- return result unless status.exitstatus.positive? || result.nil?
80
-
81
- raise Error::WebDriverError,
82
- "Unsuccessful command executed: #{command} - Code #{status.exitstatus}\n#{result}\n#{stderr}"
69
+ result
83
70
  end
84
71
 
85
72
  def platform_location
@@ -98,6 +85,38 @@ module Selenium
98
85
  raise Error::WebDriverError, "unsupported platform: #{Platform.os}"
99
86
  end
100
87
  end
88
+
89
+ def execute_command(*command)
90
+ WebDriver.logger.debug("Executing Process #{command}", id: :selenium_manager)
91
+
92
+ Open3.capture3(*command)
93
+ rescue StandardError => e
94
+ raise Error::WebDriverError, "Unsuccessful command executed: #{command}; #{e.message}"
95
+ end
96
+
97
+ def parse_result_and_log(stdout)
98
+ json_output = stdout.empty? ? {'logs' => [], 'result' => {}} : JSON.parse(stdout)
99
+
100
+ json_output['logs'].each do |log|
101
+ level = log['level'].casecmp('info').zero? ? 'debug' : log['level'].downcase
102
+ WebDriver.logger.send(level, log['message'], id: :selenium_manager)
103
+ end
104
+
105
+ json_output['result']
106
+ end
107
+
108
+ def validate_command_result(command, status, result, stderr)
109
+ if status.nil? || status.exitstatus.nil?
110
+ WebDriver.logger.info("No exit status for: #{command}. Assuming success if result is present.",
111
+ id: :selenium_manager)
112
+ end
113
+
114
+ return unless status&.exitstatus&.positive? || result.nil?
115
+
116
+ code = status&.exitstatus || 'exit status not available'
117
+ raise Error::WebDriverError,
118
+ "Unsuccessful command executed: #{command} - Code #{code}\n#{result}\n#{stderr}"
119
+ end
101
120
  end
102
121
  end # SeleniumManager
103
122
  end # WebDriver
@@ -87,6 +87,7 @@ require 'selenium/webdriver/common/driver_extensions/has_casting'
87
87
  require 'selenium/webdriver/common/driver_extensions/has_launching'
88
88
  require 'selenium/webdriver/common/driver_extensions/has_fedcm_dialog'
89
89
  require 'selenium/webdriver/common/keys'
90
+ require 'selenium/webdriver/common/print_options'
90
91
  require 'selenium/webdriver/common/profile_helper'
91
92
  require 'selenium/webdriver/common/options'
92
93
  require 'selenium/webdriver/common/takes_screenshot'
@@ -64,9 +64,9 @@ module Selenium
64
64
 
65
65
  @options[:args] ||= []
66
66
  @options[:prefs] ||= {}
67
- # Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference will enable it.
68
67
  # https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/.
69
- @options[:prefs]['remote.active-protocols'] = 3
68
+ # Enable BiDi only
69
+ @options[:prefs]['remote.active-protocols'] = 1
70
70
  @options[:env] ||= {}
71
71
  @options[:log] ||= {level: log_level} if log_level
72
72
 
@@ -25,6 +25,15 @@ module Selenium
25
25
  EXECUTABLE = 'geckodriver'
26
26
  SHUTDOWN_SUPPORTED = false
27
27
  DRIVER_PATH_ENV_KEY = 'SE_GECKODRIVER'
28
+
29
+ def initialize(path: nil, port: nil, log: nil, args: nil)
30
+ args ||= []
31
+ unless args.any? { |arg| arg.include?('--connect-existing') }
32
+ args << '--websocket-port'
33
+ args << WebDriver::PortProber.above(9222).to_s
34
+ end
35
+ super
36
+ end
28
37
  end # Service
29
38
  end # Firefox
30
39
  end # WebDriver
@@ -37,8 +37,10 @@ module Selenium
37
37
  @messages = {}
38
38
  end
39
39
 
40
- def add_condition(name, condition = nil, &block)
40
+ def add_condition(name, condition = false, &block)
41
+ condition = false if condition.nil?
41
42
  @guard_conditions << GuardCondition.new(name, condition, &block)
43
+ WebDriver.logger.debug "Running with Guard '#{name}' set to: #{condition}"
42
44
  end
43
45
 
44
46
  def add_message(name, message)
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
- VERSION = '4.31.0'
22
+ VERSION = '4.32.0'
23
23
  end # WebDriver
24
24
  end # Selenium
@@ -59,10 +59,10 @@ Gem::Specification.new do |s|
59
59
  s.add_development_dependency 'rack', ['~> 2.0']
60
60
  s.add_development_dependency 'rake', ['~> 13.0']
61
61
  s.add_development_dependency 'rspec', ['~> 3.0']
62
- s.add_development_dependency 'rubocop', ['~> 1.60', '>=1.60.2']
63
- s.add_development_dependency 'rubocop-performance', ['~> 1.15']
64
- s.add_development_dependency 'rubocop-rake', ['~> 0.6.0']
65
- s.add_development_dependency 'rubocop-rspec', ['~> 2.16']
62
+ s.add_development_dependency 'rubocop', ['~> 1.75']
63
+ s.add_development_dependency 'rubocop-performance', ['~> 1.25']
64
+ s.add_development_dependency 'rubocop-rake', ['~> 0.7']
65
+ s.add_development_dependency 'rubocop-rspec', ['~> 3.5']
66
66
  s.add_development_dependency 'webmock', ['~> 3.5']
67
67
  s.add_development_dependency 'webrick', ['~> 1.7']
68
68
  s.add_development_dependency 'yard', ['~> 0.9.11', '>= 0.9.36']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.31.0
4
+ version: 4.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Rodionov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2025-04-05 00:00:00.000000000 Z
13
+ date: 2025-05-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: base64
@@ -156,62 +156,56 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '1.60'
160
- - - ">="
161
- - !ruby/object:Gem::Version
162
- version: 1.60.2
159
+ version: '1.75'
163
160
  type: :development
164
161
  prerelease: false
165
162
  version_requirements: !ruby/object:Gem::Requirement
166
163
  requirements:
167
164
  - - "~>"
168
165
  - !ruby/object:Gem::Version
169
- version: '1.60'
170
- - - ">="
171
- - !ruby/object:Gem::Version
172
- version: 1.60.2
166
+ version: '1.75'
173
167
  - !ruby/object:Gem::Dependency
174
168
  name: rubocop-performance
175
169
  requirement: !ruby/object:Gem::Requirement
176
170
  requirements:
177
171
  - - "~>"
178
172
  - !ruby/object:Gem::Version
179
- version: '1.15'
173
+ version: '1.25'
180
174
  type: :development
181
175
  prerelease: false
182
176
  version_requirements: !ruby/object:Gem::Requirement
183
177
  requirements:
184
178
  - - "~>"
185
179
  - !ruby/object:Gem::Version
186
- version: '1.15'
180
+ version: '1.25'
187
181
  - !ruby/object:Gem::Dependency
188
182
  name: rubocop-rake
189
183
  requirement: !ruby/object:Gem::Requirement
190
184
  requirements:
191
185
  - - "~>"
192
186
  - !ruby/object:Gem::Version
193
- version: 0.6.0
187
+ version: '0.7'
194
188
  type: :development
195
189
  prerelease: false
196
190
  version_requirements: !ruby/object:Gem::Requirement
197
191
  requirements:
198
192
  - - "~>"
199
193
  - !ruby/object:Gem::Version
200
- version: 0.6.0
194
+ version: '0.7'
201
195
  - !ruby/object:Gem::Dependency
202
196
  name: rubocop-rspec
203
197
  requirement: !ruby/object:Gem::Requirement
204
198
  requirements:
205
199
  - - "~>"
206
200
  - !ruby/object:Gem::Version
207
- version: '2.16'
201
+ version: '3.5'
208
202
  type: :development
209
203
  prerelease: false
210
204
  version_requirements: !ruby/object:Gem::Requirement
211
205
  requirements:
212
206
  - - "~>"
213
207
  - !ruby/object:Gem::Version
214
- version: '2.16'
208
+ version: '3.5'
215
209
  - !ruby/object:Gem::Dependency
216
210
  name: webmock
217
211
  requirement: !ruby/object:Gem::Requirement
@@ -383,6 +377,7 @@ files:
383
377
  - lib/selenium/webdriver/common/options.rb
384
378
  - lib/selenium/webdriver/common/platform.rb
385
379
  - lib/selenium/webdriver/common/port_prober.rb
380
+ - lib/selenium/webdriver/common/print_options.rb
386
381
  - lib/selenium/webdriver/common/profile_helper.rb
387
382
  - lib/selenium/webdriver/common/proxy.rb
388
383
  - lib/selenium/webdriver/common/script.rb