dequelabs / axe-cli

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

Working on OSX, but not working on dockerized linux #66

Closed jaimeiniesta closed 6 years ago

jaimeiniesta commented 6 years ago

I have a project with these dependencied:

{
  "dependencies": {
    "axe-core": "3.0.3",
    "axe-cli": "3.0.0"
  }
}

If I run npm install from my dev machine (OSX High Sierra), I can successfully run ./node_modules/axe-cli/axe-cli http://example.com, it runs fine with chrome-headless.

But then if I delete the node_modules folder and I enter into a Docker container, I run npm install, it goes fine and gets the linux binary for chromedriver, but when I run axe-cli it fails with:

root@983181af70ec:/app# ./node_modules/axe-cli/axe-cli http://example.com
Running axe-core 3.0.3 in chrome-headless
/app/node_modules/selenium-webdriver/lib/promise.js:2626
        throw error;
        ^

Error: Server terminated early with status 127
    at earlyTermination.catch.e (/app/node_modules/selenium-webdriver/remote/index.js:252:52)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebDriver.createSession()
    at Function.createSession (/app/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
    at Function.createSession (/app/node_modules/selenium-webdriver/chrome.js:761:15)
    at createDriver (/app/node_modules/selenium-webdriver/index.js:170:33)
    at Builder.build (/app/node_modules/selenium-webdriver/index.js:642:16)
    at startDriver (/app/node_modules/axe-cli/lib/webdriver.js:33:27)
    at testPages (/app/node_modules/axe-cli/lib/axe-test-urls.js:11:10)
    at Object.<anonymous> (/app/node_modules/axe-cli/index.js:73:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)

Does it ring any bell?

jaimeiniesta commented 6 years ago

It looks like I can run chromedriver when installed in OSX:

➔ /Users/jaime/code/serverless/axe-chrome/node_modules/chromedriver/lib/chromedriver/chromedriver
Starting ChromeDriver 2.40.565386 (45a059dc425e08165f9a10324bd1380cc13ca363) on port 9515
Only local connections are allowed.

But I can't run it when installed in the Docker container:

root@9187e7fcaf36:/app# /app/node_modules/chromedriver/lib/chromedriver/chromedriver
/app/node_modules/chromedriver/lib/chromedriver/chromedriver: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
jaimeiniesta commented 6 years ago

When tried in AWS Lambda, the error is different

/var/task/node_modules/selenium-webdriver/lib/promise.js:2626
        throw error;
        ^

WebDriverError: unknown error: cannot find Chrome binary
  (Driver info: chromedriver=2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7),platform=Linux 4.9.93-41.60.amzn1.x86_64 x86_64)
    at Object.checkLegacyResponse (/var/task/node_modules/selenium-webdriver/lib/error.js:546:15)
    at parseHttpResponse (/var/task/node_modules/selenium-webdriver/lib/http.js:509:13)
    at doSend.then.response (/var/task/node_modules/selenium-webdriver/lib/http.js:441:30)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebDriver.createSession()
    at Function.createSession (/var/task/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
    at Function.createSession (/var/task/node_modules/selenium-webdriver/chrome.js:761:15)
    at createDriver (/var/task/node_modules/selenium-webdriver/index.js:170:33)
    at Builder.build (/var/task/node_modules/selenium-webdriver/index.js:642:16)
    at startDriver (/var/task/node_modules/axe-cli/lib/webdriver.js:33:27)
    at testPages (/var/task/node_modules/axe-cli/lib/axe-test-urls.js:11:10)
    at Object.<anonymous> (/var/task/node_modules/axe-cli/index.js:73:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)

    at ChildProcess.exithandler (child_process.js:275:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
  killed: false,
  code: 1,
  signal: null
jaimeiniesta commented 6 years ago

How can I specify the location of the chromedriver binary? I've tried adding /var/task/node_modules/chromedriver/lib/chromedriver to the process.env['PATH'] (where /var/task is the root of my script) but it makes no difference.

WilcoFiers commented 6 years ago

The error message comes from Chromedriver not being able to locate Chrome. As far as I can tell Chrome isn't installed in a place Chromedriver expects it - what exactly that is for the machine you're running it on I couldn't tell, but I think that if you add Chrome to PATH as well it should work.

I'm closing this as it isn't an Axe-cli issue though.

jaimeiniesta commented 6 years ago

Thanks, it looks like it's selenium-webdriver who can't find the Chrome executable. We're discussing it here if you're interested https://github.com/adieuadieu/serverless-chrome/issues/143