Skip to content

[🐛 Bug]: Additional quotes wrap binary name when invoking selenium_manager #12479

@rturner-edjuster

Description

@rturner-edjuster

What happened?

In common/seleniumManager.js, in driverLocation when the vendorOptions.binary value is added as an argument, additional quotes are added. I suspect this might be needed on Windows when the executable path contains spaces, however, on macOS, this results in the quotes being part of the binary name and the executable cannot be found as a result.

Removing these additional quotes seems to "solve" the problem on macOS.

Running Selenium Manager by itself, e.g.:
<path-to-node_modules>/selenium-webdriver/bin/macos/selenium-manager --browser chrome --browser-path "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --output json

Results in the correct output and the expected values.

If you add console.log("Output: ", output); before the final logOutput call in driverLocation, you can observe the quotes now included in the JSON output as part of the browser path:

Setting Chrome binary path to /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Selenium Manager binary found at /<redacted>/node_modules/selenium-webdriver/bin/macos/selenium-manager
output:  {
  logs: [
    {
      level: 'INFO',
      timestamp: 1691001489,
      message: 'Driver path: /<redacted>/node_modules/chromedriver/lib/chromedriver/chromedriver'
    },
    {
      level: 'INFO',
      timestamp: 1691001489,
      message: 'Browser path: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"'
    }
  ],
  result: {
    code: 0,
    message: '/<redacted>/node_modules/chromedriver/lib/chromedriver/chromedriver',
    driver_path: '/<redacted>/node_modules/chromedriver/lib/chromedriver/chromedriver',
    browser_path: '"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"'
  }
}
Driver path: /<redacted>/node_modules/chromedriver/lib/chromedriver/chromedriver
Browser path: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"

How can we reproduce the issue?

To reproduce, use something like the following:


const {Builder} = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');

(async function example() {
  let options = new chrome.Options()
      .setChromeBinaryPath('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome');
     
  let driver = await new Builder()
      .forBrowser('chrome')
      .setChromeOptions(options)
      .build();

  try {
    await driver.get('http://www.google.com/');
  } finally {
    await driver.quit();
  }
})();

Relevant log output

WITH CURRENT CODE WITH QUOTES:

Setting Chrome binary path to /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Selenium Manager binary found at /<redacted>/node_modules/selenium-webdriver/bin/macos/selenium-manager
Driver path: /<redacted>/node_modules/chromedriver/lib/chromedriver/chromedriver
Browser path: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
ERROR: Failed to wait for first driver to start, can't continue [AggregateError: All promises were rejected] {
  [errors]: [
    WebDriverError: unknown error: no chrome binary at "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"


AFTER REMOVING THE QUOTES:

Setting Chrome binary path to /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Selenium Manager binary found at /<redacted>/node_modules/selenium-webdriver/bin/macos/selenium-manager
Driver path: /<redacted>/node_modules/chromedriver/lib/chromedriver/chromedriver
Browser path: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

Operating System

macOS 13.5 (arm64)

Selenium version

4.11.1

What are the browser(s) and version(s) where you see this issue?

Chrome 115.x

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 115.x

Are you using Selenium Grid?

no

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-nodejsJavaScript BindingsI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions