dequelabs / axe-webdriverjs

Provides a chainable axe API for Selenium's WebDriverJS and automatically injects into all frames.
Mozilla Public License 2.0
130 stars 46 forks source link

Undefined is not an object #50

Closed b-sharpe closed 6 years ago

b-sharpe commented 6 years ago

If I use anything above 1.2.0 I get the following on analyze()

WebDriverError: {"errorMessage":"undefined is not an object (evaluating 'window.axe.run(context || document, options || {})

I'm guessing it's the promise change in 1.3.0, but can't figure out why that would be.

WilcoFiers commented 6 years ago

Can you provide us with a codepen or something so we can reproduce the issue? We've certainly not seen this before (and we have updated and ran tests against the latest versions of aXe).

b-sharpe commented 6 years ago

Even a simple index.js with your sample is giving the error:

var AxeBuilder = require('axe-webdriverjs');
var WebDriver = require('selenium-webdriver');

var driver = new WebDriver.Builder()
  .forBrowser('phantomjs')
  .build();

driver
  .get('https://dequeuniversity.com/demo/mars/')
  .then(function () {
    AxeBuilder(driver)
      .analyze(function (results) {
        console.log(results);
      });
  });

I was using phantomjs since I was on a non-display machine, so I switched to my mac and get the same error with phantomjs, if I switch the browser to Chrome, I see the browser open the page, and then I get the following error instead: UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): WebDriverError: unknown error: missing or invalid 'entry.level'

This is the package.json:

{
  "name": "testing",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "axe-webdriverjs": "^1.3.0",
    "phantomjs-prebuilt": "^2.1.16",
    "selenium-webdriver": "^3.5.0"
  }
}
b-sharpe commented 6 years ago

If I change to "axe-webdriverjs": "1.2.0", and reinstall, the exact same code works.

marcysutton commented 6 years ago

It works with a real browser like Chrome, but not with PhantomJS. I don't think we're going to support Phantom with this project, to be honest.

FWIW I did get it to work when wrapped in an actual jasmine/mocha test.

b-sharpe commented 6 years ago

Looks like core does, so maybe I can do without the webdriver? https://axe-core.org/examples/phantomjs.html

marcysutton commented 6 years ago

We're phasing it out soon in favor of headless Chrome, so I wouldn't count on Phantom being supported for too much longer.