Skip to content

The --javaArgs argument is parsed incorrectly when using the CLI #736

Closed
@MackinnonBuck

Description

@MackinnonBuck

Summary

When using the command line interface, the --javaArgs argument value gets interpreted as a string and expanded to an array containing each character in the string. For example, in the case of --javaArgs=-Dfoobar, the "-Dfoobar" gets expanded to ['-', 'D', 'f', 'o', 'o', 'b,' 'a', 'r'].

This is where the expansion occurs:

args.push(...opts.javaArgs, '-jar', fsPaths.selenium.installPath, ...opts.seleniumArgs);

This is fine when using the API directly, because opts.javaArgs is expected to be an array. However, the parsing logic for the CLI doesn't appear to take this into account.

Expected Behavior

The --javaArgs argument value should be correctly parsed and passed through to selenium-server.

Current Behavior

Each character in the --javaArgs argument value is passed as a separate argument to selenium-server.

Steps to Reproduce

npm install selenium-standalone -g
selenium-standalone install
selenium-standalone start --javaArgs=-Xmx512m

Logs

Unrecognized option: -
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
/home/currentuser/.nvm/versions/node/v16.17.1/lib/node_modules/selenium-standalone/lib/check-started.js:44
      throw new Error(
            ^

Error: Selenium exited before it could start with code 1
Stdout:
Stderr:
    at checkStarted (/home/currentuser/.nvm/versions/node/v16.17.1/lib/node_modules/selenium-standalone/lib/check-started.js:44:13)
    at async Object.start (/home/currentuser/.nvm/versions/node/v16.17.1/lib/node_modules/selenium-standalone/lib/start.js:160:3)
    at async Object.start (/home/currentuser/.nvm/versions/node/v16.17.1/lib/node_modules/selenium-standalone/bin/selenium-standalone:23:16)

Your Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions