Skip to content

Commit 1a22a8b

Browse files
committed
Do not escape selenium-manager arguments
1 parent 8bd2c5e commit 1a22a8b

3 files changed

Lines changed: 12 additions & 22 deletions

File tree

rb/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PATH
33
specs:
44
selenium-devtools (0.111.0)
55
selenium-webdriver (~> 4.2)
6-
selenium-webdriver (4.8.3)
6+
selenium-webdriver (4.8.5)
77
rexml (~> 3.2, >= 3.2.5)
88
rubyzip (>= 1.2.2, < 3.0)
99
websocket (~> 1.0)

rb/lib/selenium/webdriver/common/selenium_manager.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ def driver_path(options)
4040
raise ArgumentError, "SeleniumManager requires a WebDriver::Options instance, not #{options.inspect}"
4141
end
4242

43-
command = [binary, '--browser', "'#{options.browser_name}'", '--output', 'json']
43+
command = [binary, '--browser', options.browser_name, '--output', 'json']
4444
if options.browser_version
4545
command << '--browser-version'
4646
command << options.browser_version
4747
end
4848
if options.respond_to?(:binary) && !options.binary.nil?
4949
command << '--browser-path'
50-
command << "\"#{options.binary.gsub('\ ', ' ').gsub(' ', '\ ')}\""
50+
command << options.binary
5151
end
5252
command << '--debug' if WebDriver.logger.debug?
5353

54-
location = run(command.join(' '))
54+
location = run(*command)
5555
WebDriver.logger.debug("Driver found at #{location}")
5656
Platform.assert_executable location
5757

@@ -81,11 +81,11 @@ def binary
8181
end
8282
end
8383

84-
def run(command)
84+
def run(*command)
8585
WebDriver.logger.debug("Executing Process #{command}")
8686

8787
begin
88-
stdout, stderr, status = Open3.capture3(command)
88+
stdout, stderr, status = Open3.capture3(*command)
8989
json_output = stdout.empty? ? nil : JSON.parse(stdout)
9090
result = json_output&.dig('result', 'message')
9191
rescue StandardError => e

rb/spec/unit/selenium/webdriver/common/selenium_manager_spec.rb

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ module WebDriver
8585

8686
described_class.driver_path(Options.chrome)
8787

88-
expect(described_class).to have_received(:run).with("selenium-manager --browser 'chrome' --output json")
88+
expect(described_class).to have_received(:run)
89+
.with('selenium-manager', '--browser', 'chrome', '--output', 'json')
8990
end
9091

9192
it 'uses browser version if specified' do
@@ -97,7 +98,7 @@ module WebDriver
9798
described_class.driver_path(options)
9899

99100
expect(described_class).to have_received(:run)
100-
.with("selenium-manager --browser 'chrome' --output json --browser-version 1")
101+
.with('selenium-manager', '--browser', 'chrome', '--output', 'json', '--browser-version', 1)
101102
end
102103

103104
it 'uses browser location if specified' do
@@ -109,7 +110,7 @@ module WebDriver
109110
described_class.driver_path(options)
110111

111112
expect(described_class).to have_received(:run)
112-
.with("selenium-manager --browser 'chrome' --output json --browser-path \"/path/to/browser\"")
113+
.with('selenium-manager', '--browser', 'chrome', '--output', 'json', '--browser-path', '/path/to/browser')
113114
end
114115

115116
it 'properly escapes plain spaces in browser location' do
@@ -121,19 +122,8 @@ module WebDriver
121122
described_class.driver_path(options)
122123

123124
expect(described_class).to have_received(:run)
124-
.with("selenium-manager --browser 'chrome' --output json --browser-path \"/path\\ to/the/browser\"")
125-
end
126-
127-
it 'properly escapes escaped spaces in browser location' do
128-
allow(described_class).to receive(:run)
129-
allow(described_class).to receive(:binary).and_return('selenium-manager')
130-
allow(Platform).to receive(:assert_executable)
131-
options = Options.chrome(binary: '/path\ to/the/browser')
132-
133-
described_class.driver_path(options)
134-
135-
expect(described_class).to have_received(:run)
136-
.with("selenium-manager --browser 'chrome' --output json --browser-path \"/path\\ to/the/browser\"")
125+
.with('selenium-manager', '--browser', 'chrome', '--output', 'json',
126+
'--browser-path', '/path to/the/browser')
137127
end
138128
end
139129
end

0 commit comments

Comments
 (0)