selenium-webdriver 4.19.0 → 4.20.1

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: 0ee4754e8606082979c4d9cf4a681abb0aa3e9ec3cc32de11852eae881265f8c
4
- data.tar.gz: 6969fecd90f1d5c6fac4c3a0def5534e09194e54ac84b9e333f6e55c8094a3ad
3
+ metadata.gz: c32a4152c7c47427939aba71e601004ee0cd8ad0c2454b00b879d0bd84f01a5e
4
+ data.tar.gz: d7cf6a825f70df0366b290da8e7fbf36417bcabe055f1835eca9402b6c37c791
5
5
  SHA512:
6
- metadata.gz: af6a34ae5e3b18486f605f97bf4112030dddebf90a19a94a4a0585fc5026d8b10e51241ea360f550951179a3dbbe088a7ad02f1b3a7fd1ee1b0e43c836ddbd7a
7
- data.tar.gz: 0621f20b80fd5430b945c9ff3eddad18b86bbcdb7c1aea517c60be373096fef3afb2c9eeee33f8c10cfb8ce70231e41d11893855277ccd9d09ea59683e67cfd3
6
+ metadata.gz: 6f121cc65df3f7174419ab881de0f8283e2bbb22698aa7582f019b1a2e3f7aae04376d0be02507ffbc968fe95512c97fb121515a16a9ff62b845a23e939005f7
7
+ data.tar.gz: f0b0dfba817532e5cd9ab1ab0874463823434dcdac0f15efe199d400a53539343cdcaafdecf766596dc36cbc52c6e0454784a44fc748c21e6dc380d279bb29e4
data/CHANGES CHANGED
@@ -1,3 +1,17 @@
1
+ 4.20.1 (2024-04-25)
2
+ =========================
3
+
4
+ * Returned accidentally removed DriverFinder.path and deprecated it.
5
+
6
+ 4.20.0 (2024-04-24)
7
+ =========================
8
+
9
+ * Add CDP for Chrome 124 and remove 121
10
+ * Making Selenium Manager a thin wrapper (#13386)
11
+ * This change has been made to make it easier to maintain and improve, the interface has
12
+ changed and if users were invoking it, they might experience issues. Selenium Manager is
13
+ still in beta and these type of changes are expected.
14
+
1
15
  4.19.0 (2024-03-27)
2
16
  =========================
3
17
 
Binary file
Binary file
Binary file
@@ -105,8 +105,8 @@ function gd(a){var b=a.shape.toLowerCase();a=a.coords.split(",");if("rect"==b&&4
105
105
  function hd(a){return a.replace(/^[^\S\xa0]+|[^\S\xa0]+$/g,"")}function id(a){var b=[];Yc?jd(a,b):kd(a,b);a=qa(b,hd);return hd(a.join("\n")).replace(/\xa0/g," ")}
106
106
  function ld(a,b,c){if(S(a,"BR"))b.push("");else{var d=S(a,"TD"),e=U(a,"display"),f=!d&&!(0<=oa(md,e)),g=void 0!==a.previousElementSibling?a.previousElementSibling:gb(a.previousSibling);g=g?U(g,"display"):"";var h=U(a,"float")||U(a,"cssFloat")||U(a,"styleFloat");!f||"run-in"==g&&"none"==h||/^[\s\xa0]*$/.test(b[b.length-1]||"")||b.push("");var n=ed(a),u=null,p=null;n&&(u=U(a,"white-space"),p=U(a,"text-transform"));l(a.childNodes,function(G){c(G,b,n,u,p)});a=b[b.length-1]||"";!d&&"table-cell"!=e||!a||
107
107
  za(a)||(b[b.length-1]+=" ");f&&"run-in"!=e&&!/^[\s\xa0]*$/.test(a)&&b.push("")}}function kd(a,b){ld(a,b,function(c,d,e,f,g){3==c.nodeType&&e?nd(c,d,f,g):S(c)&&kd(c,d)})}var md="inline inline-block inline-table none table-cell table-column table-column-group".split(" ");
108
- function nd(a,b,c,d){a=a.nodeValue.replace(/[\u200b\u200e\u200f]/g,"");a=a.replace(/(\r\n|\r|\n)/g,"\n");if("normal"==c||"nowrap"==c)a=a.replace(/\n/g," ");a="pre"==c||"pre-wrap"==c?a.replace(/[ \f\t\v\u2028\u2029]/g,"\u00a0"):a.replace(/[ \f\t\v\u2028\u2029]+/g," ");"capitalize"==d?a=a.replace(t?/(^|\s|\b)(\S)/g:/(^|[^\d\p{L}\p{S}])([\p{Ll}|\p{S}])/gu,function(e,f,g){return f+g.toUpperCase()}):"uppercase"==d?a=a.toUpperCase():"lowercase"==d&&(a=a.toLowerCase());c=b.pop()||"";za(c)&&0==a.lastIndexOf(" ",
109
- 0)&&(a=a.substr(1));b.push(c+a)}function dd(a){if(Mc){if("relative"==U(a,"position"))return 1;a=U(a,"filter");return(a=a.match(/^alpha\(opacity=(\d*)\)/)||a.match(/^progid:DXImageTransform.Microsoft.Alpha\(Opacity=(\d*)\)/))?Number(a[1])/100:1}return od(a)}function od(a){var b=1,c=U(a,"opacity");c&&(b=Number(c));(a=Zc(a))&&(b*=od(a));return b}
108
+ function nd(a,b,c,d){a=a.nodeValue.replace(/[\u200b\u200e\u200f]/g,"");a=a.replace(/(\r\n|\r|\n)/g,"\n");if("normal"==c||"nowrap"==c)a=a.replace(/\n/g," ");a="pre"==c||"pre-wrap"==c?a.replace(/[ \f\t\v\u2028\u2029]/g,"\u00a0"):a.replace(/[ \f\t\v\u2028\u2029]+/g," ");"capitalize"==d?a=a.replace(t?/(^|\s|\b)(\S)/g:/(^|\s|\b)(\S)/gu,function(e,f,g){return f+g.toUpperCase()}):"uppercase"==d?a=a.toUpperCase():"lowercase"==d&&(a=a.toLowerCase());c=b.pop()||"";za(c)&&0==a.lastIndexOf(" ",0)&&(a=a.substr(1));
109
+ b.push(c+a)}function dd(a){if(Mc){if("relative"==U(a,"position"))return 1;a=U(a,"filter");return(a=a.match(/^alpha\(opacity=(\d*)\)/)||a.match(/^progid:DXImageTransform.Microsoft.Alpha\(Opacity=(\d*)\)/))?Number(a[1])/100:1}return od(a)}function od(a){var b=1,c=U(a,"opacity");c&&(b=Number(c));(a=Zc(a))&&(b*=od(a));return b}
110
110
  function pd(a,b,c,d,e){if(3==a.nodeType&&c)nd(a,b,d,e);else if(S(a))if(S(a,"CONTENT")||S(a,"SLOT")){for(var f=a;f.parentNode;)f=f.parentNode;f instanceof ShadowRoot?(f=S(a,"CONTENT")?a.getDistributedNodes():a.assignedNodes(),l(0<f.length?f:a.childNodes,function(g){pd(g,b,c,d,e)})):jd(a,b)}else if(S(a,"SHADOW")){for(f=a;f.parentNode;)f=f.parentNode;if(f instanceof ShadowRoot&&(a=f))for(a=a.olderShadowRoot;a;)l(a.childNodes,function(g){pd(g,b,c,d,e)}),a=a.olderShadowRoot}else jd(a,b)}
111
111
  function jd(a,b){a.shadowRoot&&l(a.shadowRoot.childNodes,function(c){pd(c,b,!0,null,null)});ld(a,b,function(c,d,e,f,g){var h=null;1==c.nodeType?h=c:3==c.nodeType&&(h=c);null!=h&&(null!=h.assignedSlot||h.getDestinationInsertionPoints&&0<h.getDestinationInsertionPoints().length)||pd(c,d,e,f,g)})};var qd={C:function(a,b){return!(!a.querySelectorAll||!a.querySelector)&&!/^\d.*/.test(b)},o:function(a,b){var c=eb(b),d="string"===typeof a?c.a.getElementById(a):a;return d?Uc(d,"id")==a&&b!=d&&hb(b,d)?d:ua(mb(c,"*"),function(e){return Uc(e,"id")==a&&b!=e&&hb(b,e)}):null},j:function(a,b){if(!a)return[];if(qd.C(b,a))try{return b.querySelectorAll("#"+qd.T(a))}catch(c){return[]}b=mb(eb(b),"*",null,b);return pa(b,function(c){return Uc(c,"id")==a})},T:function(a){return a.replace(/([\s'"\\#.:;,!?+<>=~*^$|%&@`{}\-\/\[\]\(\)])/g,
112
112
  "\\$1")}};var X={},rd={};X.N=function(a,b,c){try{var d=Nc.j("a",b)}catch(e){d=mb(eb(b),"A",null,b)}return ua(d,function(e){e=id(e);e=e.replace(/^[\s]+|[\s]+$/g,"");return c&&-1!=e.indexOf(a)||e==a})};X.K=function(a,b,c){try{var d=Nc.j("a",b)}catch(e){d=mb(eb(b),"A",null,b)}return pa(d,function(e){e=id(e);e=e.replace(/^[\s]+|[\s]+$/g,"");return c&&-1!=e.indexOf(a)||e==a})};X.o=function(a,b){return X.N(a,b,!1)};X.j=function(a,b){return X.K(a,b,!1)};rd.o=function(a,b){return X.N(a,b,!0)};
@@ -20,25 +20,70 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  class DriverFinder
23
- def self.path(options, klass)
24
- path = klass.driver_path
25
- path = path.call if path.is_a?(Proc)
23
+ def self.path(options, service_class)
24
+ WebDriver.logger.deprecate('DriverFinder.path(options, service_class)',
25
+ 'DriverFinder.new(options, service).driver_path')
26
+ new(options, service_class.new).driver_path
27
+ end
28
+
29
+ def initialize(options, service)
30
+ @options = options
31
+ @service = service
32
+ end
33
+
34
+ def browser_path
35
+ paths[:browser_path]
36
+ end
37
+
38
+ def driver_path
39
+ paths[:driver_path]
40
+ end
26
41
 
27
- path ||= begin
28
- SeleniumManager.driver_path(options) unless options.is_a?(Remote::Capabilities)
42
+ def browser_path?
43
+ !browser_path.nil? && !browser_path.empty?
44
+ end
45
+
46
+ private
47
+
48
+ def paths
49
+ @paths ||= begin
50
+ path = @service.class.driver_path
51
+ path = path.call if path.is_a?(Proc)
52
+ exe = @service.class::EXECUTABLE
53
+ if path
54
+ WebDriver.logger.debug("Skipping Selenium Manager; path to #{exe} specified in service class: #{path}")
55
+ Platform.assert_executable(path)
56
+ {driver_path: path}
57
+ else
58
+ output = SeleniumManager.binary_paths(*to_args)
59
+ formatted = {driver_path: Platform.cygwin_path(output['driver_path'], only_cygwin: true),
60
+ browser_path: Platform.cygwin_path(output['browser_path'], only_cygwin: true)}
61
+ Platform.assert_executable(formatted[:driver_path])
62
+ Platform.assert_executable(formatted[:browser_path])
63
+ formatted
64
+ end
29
65
  rescue StandardError => e
30
- raise Error::NoSuchDriverError, "Unable to obtain #{klass::EXECUTABLE} using Selenium Manager; #{e.message}"
66
+ WebDriver.logger.error("Exception occurred: #{e.message}")
67
+ WebDriver.logger.error("Backtrace:\n\t#{e.backtrace&.join("\n\t")}")
68
+ raise Error::NoSuchDriverError, "Unable to obtain #{exe}"
31
69
  end
70
+ end
32
71
 
33
- begin
34
- Platform.assert_executable(path)
35
- rescue TypeError
36
- raise Error::NoSuchDriverError, "Unable to locate or obtain #{klass::EXECUTABLE}"
37
- rescue Error::WebDriverError => e
38
- raise Error::NoSuchDriverError, "#{klass::EXECUTABLE} located, but: #{e.message}"
72
+ def to_args
73
+ args = ['--browser', @options.browser_name]
74
+ if @options.browser_version
75
+ args << '--browser-version'
76
+ args << @options.browser_version
39
77
  end
40
-
41
- path
78
+ if @options.respond_to?(:binary) && !@options.binary.nil?
79
+ args << '--browser-path'
80
+ args << @options.binary.gsub('\\', '\\\\\\')
81
+ end
82
+ if @options.proxy
83
+ args << '--proxy'
84
+ args << (@options.proxy.ssl || @options.proxy.http)
85
+ end
86
+ args
42
87
  end
43
88
  end
44
89
  end
@@ -38,7 +38,14 @@ module Selenium
38
38
  raise ArgumentError, ":options must be an instance of #{default_options.class}"
39
39
  end
40
40
 
41
- service.executable_path ||= WebDriver::DriverFinder.path(options, service.class)
41
+ service.executable_path ||= begin
42
+ finder = WebDriver::DriverFinder.new(options, service)
43
+ if options.respond_to?(:binary) && finder.browser_path?
44
+ options.binary = finder.browser_path
45
+ options.browser_version = nil
46
+ end
47
+ finder.driver_path
48
+ end
42
49
  options.as_json
43
50
  end
44
51
  end
@@ -111,7 +111,9 @@ module Selenium
111
111
  windows? && !cygwin? ? %("#{str}") : str
112
112
  end
113
113
 
114
- def cygwin_path(path, **opts)
114
+ def cygwin_path(path, only_cygwin: false, **opts)
115
+ return path if only_cygwin && !cygwin?
116
+
115
117
  flags = []
116
118
  opts.each { |k, v| flags << "--#{k}" if v }
117
119
 
@@ -34,88 +34,33 @@ module Selenium
34
34
  @bin_path ||= '../../../../../bin'
35
35
  end
36
36
 
37
- # @param [Options] options browser options.
38
- # @return [String] the path to the correct driver.
39
- def driver_path(options)
40
- command = generate_command(binary, options)
41
-
42
- output = run(*command)
43
-
44
- browser_path = Platform.cygwin? ? Platform.cygwin_path(output['browser_path']) : output['browser_path']
45
- driver_path = Platform.cygwin? ? Platform.cygwin_path(output['driver_path']) : output['driver_path']
46
- Platform.assert_executable driver_path
47
-
48
- if options.respond_to?(:binary) && browser_path && !browser_path.empty?
49
- options.binary = browser_path
50
- options.browser_version = nil
51
- end
52
-
53
- driver_path
37
+ # @param [Array] arguments what gets sent to to Selenium Manager binary.
38
+ # @return [Hash] paths to the requested assets.
39
+ def binary_paths(*arguments)
40
+ arguments += %w[--language-binding ruby]
41
+ arguments += %w[--output json]
42
+ arguments << '--debug' if WebDriver.logger.debug?
43
+
44
+ run(binary, *arguments)
54
45
  end
55
46
 
56
47
  private
57
48
 
58
- def generate_command(binary, options)
59
- command = [binary, '--browser', options.browser_name]
60
- if options.browser_version
61
- command << '--browser-version'
62
- command << options.browser_version
63
- end
64
- if options.respond_to?(:binary) && !options.binary.nil?
65
- command << '--browser-path'
66
- command << options.binary.squeeze('\\').gsub('\\', '\\\\\\')
67
- end
68
- if options.proxy
69
- command << '--proxy'
70
- command << (options.proxy.ssl || options.proxy.http)
71
- end
72
- command
73
- end
74
-
75
49
  # @return [String] the path to the correct selenium manager
76
50
  def binary
77
51
  @binary ||= begin
78
- location = ENV.fetch('SE_MANAGER_PATH', begin
79
- directory = File.expand_path(bin_path, __FILE__)
80
- if Platform.windows?
81
- "#{directory}/windows/selenium-manager.exe"
82
- elsif Platform.mac?
83
- "#{directory}/macos/selenium-manager"
84
- elsif Platform.linux?
85
- "#{directory}/linux/selenium-manager"
86
- elsif Platform.unix?
87
- WebDriver.logger.warn('Selenium Manager binary may not be compatible with Unix; verify settings',
88
- id: %i[selenium_manager unix_binary])
89
- "#{directory}/linux/selenium-manager"
90
- end
91
- rescue Error::WebDriverError => e
92
- raise Error::WebDriverError, "Unable to obtain Selenium Manager binary for #{e.message}"
93
- end)
52
+ if (location = ENV.fetch('SE_MANAGER_PATH', nil))
53
+ WebDriver.logger.debug("Selenium Manager set by ENV['SE_MANAGER_PATH']: #{location}")
54
+ end
55
+ location ||= platform_location
94
56
 
95
- validate_location(location)
96
- location
97
- end
98
- end
99
-
100
- def validate_location(location)
101
- begin
102
- Platform.assert_file(location)
103
57
  Platform.assert_executable(location)
104
- rescue TypeError
105
- raise Error::WebDriverError,
106
- "Unable to locate or obtain Selenium Manager binary; #{location} is not a valid file object"
107
- rescue Error::WebDriverError => e
108
- raise Error::WebDriverError, "Selenium Manager binary located, but #{e.message}"
58
+ WebDriver.logger.debug("Selenium Manager binary found at #{location}", id: :selenium_manager)
59
+ location
109
60
  end
110
-
111
- WebDriver.logger.debug("Selenium Manager binary found at #{location}", id: :selenium_manager)
112
61
  end
113
62
 
114
63
  def run(*command)
115
- command += %w[--language-binding ruby]
116
- command += %w[--output json]
117
- command << '--debug' if WebDriver.logger.debug?
118
-
119
64
  WebDriver.logger.debug("Executing Process #{command}", id: :selenium_manager)
120
65
 
121
66
  begin
@@ -124,16 +69,34 @@ module Selenium
124
69
  raise Error::WebDriverError, "Unsuccessful command executed: #{command}; #{e.message}"
125
70
  end
126
71
 
127
- json_output = stdout.empty? ? {} : JSON.parse(stdout)
128
- (json_output['logs'] || []).each do |log|
72
+ json_output = stdout.empty? ? {'logs' => [], 'result' => {}} : JSON.parse(stdout)
73
+ json_output['logs'].each do |log|
129
74
  level = log['level'].casecmp('info').zero? ? 'debug' : log['level'].downcase
130
75
  WebDriver.logger.send(level, log['message'], id: :selenium_manager)
131
76
  end
132
77
 
133
78
  result = json_output['result']
134
- return result unless status.exitstatus.positive?
79
+ return result unless status.exitstatus.positive? || result.nil?
135
80
 
136
- raise Error::WebDriverError, "Unsuccessful command executed: #{command}\n#{result}#{stderr}"
81
+ raise Error::WebDriverError,
82
+ "Unsuccessful command executed: #{command} - Code #{status.exitstatus}\n#{result}\n#{stderr}"
83
+ end
84
+
85
+ def platform_location
86
+ directory = File.expand_path(bin_path, __FILE__)
87
+ if Platform.windows?
88
+ "#{directory}/windows/selenium-manager.exe"
89
+ elsif Platform.mac?
90
+ "#{directory}/macos/selenium-manager"
91
+ elsif Platform.linux?
92
+ "#{directory}/linux/selenium-manager"
93
+ elsif Platform.unix?
94
+ WebDriver.logger.warn('Selenium Manager binary may not be compatible with Unix',
95
+ id: %i[selenium_manager unix_binary])
96
+ "#{directory}/linux/selenium-manager"
97
+ else
98
+ raise Error::WebDriverError, "unsupported platform: #{Platform.os}"
99
+ end
137
100
  end
138
101
  end
139
102
  end # SeleniumManager
@@ -89,7 +89,7 @@ module Selenium
89
89
  def launch
90
90
  @executable_path ||= begin
91
91
  default_options = WebDriver.const_get("#{self.class.name&.split('::')&.[](2)}::Options").new
92
- DriverFinder.path(default_options, self.class)
92
+ DriverFinder.new(default_options, self).driver_path
93
93
  end
94
94
  ServiceManager.new(self).tap(&:start)
95
95
  end
@@ -98,7 +98,7 @@ module Selenium
98
98
  original = DevTools::Request.from(id, params)
99
99
  mutable = DevTools::Request.from(id, params)
100
100
 
101
- block.call(mutable) do |&continue| # rubocop:disable Performance/RedundantBlockCall
101
+ block.call(mutable) do |&continue|
102
102
  pending_response_requests[id] = continue
103
103
 
104
104
  if original == mutable
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
- VERSION = '4.19.0'
22
+ VERSION = '4.20.1'
23
23
  end # WebDriver
24
24
  end # Selenium
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.19.0
4
+ version: 4.20.1
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: 2024-03-27 00:00:00.000000000 Z
13
+ date: 2024-04-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: base64