dequelabs / axe-cli

[Deprecated] A command-line interface for the aXe accessibility testing engine
Mozilla Public License 2.0
430 stars 44 forks source link

--chrome-options flag doesn't work #149

Open robfentress opened 4 years ago

robfentress commented 4 years ago

Attempting to use you example of how to use the --chrome-options flag results in a WebDriverError. Here is the command and the output:

accessibility-report-tool > axe --chrome-options="no-sandbox,disable-setuid-sandbox,disable-dev-shm-usage" www.deque.com
Running axe-core 3.5.5 in chrome-headless
/Users/robfentress/.nvm/versions/node/v12.16.2/lib/node_modules/axe-cli/node_modules/selenium-webdriver/lib/promise.js:2626
        throw error;
        ^

WebDriverError: invalid argument: cannot parse capability: chromeOptions
from invalid argument: cannot parse args
from invalid argument: each argument must be a string
  (Driver info: chromedriver=84.0.4147.30 (48b3e868b4cc0aa7e8149519690b6f6949e110a8-refs/branch-heads/4147@{#310}),platform=Mac OS X 10.13.6 x86_64)
    at Object.checkLegacyResponse (/Users/robfentress/.nvm/versions/node/v12.16.2/lib/node_modules/axe-cli/node_modules/selenium-webdriver/lib/error.js:546:15)
    at parseHttpResponse (/Users/robfentress/.nvm/versions/node/v12.16.2/lib/node_modules/axe-cli/node_modules/selenium-webdriver/lib/http.js:509:13)
    at /Users/robfentress/.nvm/versions/node/v12.16.2/lib/node_modules/axe-cli/node_modules/selenium-webdriver/lib/http.js:441:30
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
From: Task: WebDriver.createSession()
    at Function.createSession (/Users/robfentress/.nvm/versions/node/v12.16.2/lib/node_modules/axe-cli/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
    at Function.createSession (/Users/robfentress/.nvm/versions/node/v12.16.2/lib/node_modules/axe-cli/node_modules/selenium-webdriver/chrome.js:761:15)
    at createDriver (/Users/robfentress/.nvm/versions/node/v12.16.2/lib/node_modules/axe-cli/node_modules/selenium-webdriver/index.js:170:33)
    at Builder.build (/Users/robfentress/.nvm/versions/node/v12.16.2/lib/node_modules/axe-cli/node_modules/selenium-webdriver/index.js:642:16)
    at startDriver (/Users/robfentress/.nvm/versions/node/v12.16.2/lib/node_modules/axe-cli/lib/webdriver.js:37:26)
    at testPages (/Users/robfentress/.nvm/versions/node/v12.16.2/lib/node_modules/axe-cli/lib/axe-test-urls.js:11:10)
    at Object.<anonymous> (/Users/robfentress/.nvm/versions/node/v12.16.2/lib/node_modules/axe-cli/index.js:136:1)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32) {
  name: 'WebDriverError',
  remoteStacktrace: ''
}
straker commented 4 years ago

Thanks for the issue. We'll look into it.

robfentress commented 4 years ago

Interestingly, it appears to work when you are running the command from the actual repository. So, if I clone axe-cli and run node index.js --chrome-options="no-sandbox,disable-setuid-sandbox,disable-dev-shm-usage" www.deque.com, then it works. However, if I install axe-cli as a global package using npm install -g axe-cli and try to run axe --chrome-options="no-sandbox,disable-setuid-sandbox,disable-dev-shm-usage" www.deque.com it throws that WebDriverError.

robfentress commented 4 years ago

After some investigation, I think the issue seems to be that lib/webdriver.js is different in the GitHub repository than in the package you install with node. In the node package, on line 23 it has the following:

args.push(config.chromeOptions);

In the version in the GitHub repository, on line 23 it instead has the following:

args.push(...config.chromeOptions);

Basically, the node package version isn't using the spread operator. Without it, an array is added to the arg, rather than a string, which is what chromedriver is expecting.

I don't know how this works, but can you push this change to npm?