Skip to content

[🐛 Bug]: Selenium manager doesn't work in paths that contain spaces #11649

@cfarmerga

Description

@cfarmerga

What happened?

I am using Windows 11 and have a simple js script that tries to build a driver using selenium manager. I see that it works fine when I have the script in a path which contains no spaces, but it fails when spaces exist in the path with this error:

c:\dev\selenium path with space>node simple.js                                                                                                                                                   
 The ChromeDriver could not be found on the current PATH, trying Selenium Manager                                                                                                                
'c:\dev\selenium' is not recognized as an internal or external command,                                                                                                                          
operable program or batch file.                                                                                                                                                                  
Unable to obtain driver using Selenium Manager: Error: Error executing command with c:\dev\selenium path with space\node_modules\selenium-webdriver\bin\windows\selenium-manager.exe,--browser,ch
rome                                                                                                                                                                                             
'c:\dev\selenium' is not recognized as an internal or external command,                                                                                                                          
operable program or batch file.                                                                                                                                                                  
                                                                                                                                                                                                 
c:\dev\selenium path with space\node_modules\selenium-webdriver\chrome.js:175                                                                                                                    
      throw Error(                                                                                                                                                                               
            ^        

I see that the cause seems to be the code in selenium-webdriver/common/seleniumManager.js (line 76), where the driverLocation function tries to use the result of getBinary() directly in execSync. It seems like this path should be quoted before being passed to execSync.

Also posted to https://stackoverflow.com/questions/75438848/selenium-builder-failing-with-spaces-in-path

How can we reproduce the issue?

package.json:
{
  "type": "commonjs",
  "dependencies": {
    "selenium-webdriver": "4.8.0"
  }
}


Here's the relevant code:

const { Builder, Browser } = require("selenium-webdriver");

(async function example() {
  const driver = await new Builder().forBrowser(Browser.CHROME).build();
  driver.get("https://stackoverflow.com");
})();

Relevant log output

c:\dev\selenium path with space>node simple.js                                                                                                                                                   
 The ChromeDriver could not be found on the current PATH, trying Selenium Manager                                                                                                                
'c:\dev\selenium' is not recognized as an internal or external command,                                                                                                                          
operable program or batch file.                                                                                                                                                                  
Unable to obtain driver using Selenium Manager: Error: Error executing command with c:\dev\selenium path with space\node_modules\selenium-webdriver\bin\windows\selenium-manager.exe,--browser,ch
rome                                                                                                                                                                                             
'c:\dev\selenium' is not recognized as an internal or external command,                                                                                                                          
operable program or batch file.

Operating System

Windows 11

Selenium version

javascript 4.8.0

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

Chrome

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

Any

Are you using Selenium Grid?

No response

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