axe-core-npm icon indicating copy to clipboard operation
axe-core-npm copied to clipboard

Axe puppeteer hangs when JS is disabled

Open michaelchiche opened this issue 3 years ago • 3 comments

Product: puppeteer

Expectation: I tried to make it work with Javascript disabled on the page, and the analyze function just hangs, i dont know if this is wanted/expected behavior of if there is a way to make it work, or improve the error handling?

Actual: It hangs with Js disabled on the page Motivation: from what i know, we only read the dom and see if the elements answer some rules. why do we need js to make it work. It also helps save some time because it renders the page from the server only.

import { AxePuppeteer } from '@axe-core/puppeteer';
import puppeteer from 'puppeteer';

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.setBypassCSP(true);
  await page.setJavaScriptEnabled(false);

  await page.goto('https://dequeuniversity.com/demo/mars/');
  console.log('before results');

  const results = await new AxePuppeteer(page).analyze();
  console.log(results);

  await page.close();
  await browser.close();
})();


@axe-core/[email protected]

- Node version: 16.15.1
- Platform:  Linux

michaelchiche avatar Jun 16 '22 19:06 michaelchiche

I read the code a little bit, it looks like the package runs JS inside the page, so maybe it should be documented?

michaelchiche avatar Jun 16 '22 19:06 michaelchiche

Yes, all of our integrations run axe-core on the page you are analyzing, which requires JavaScript to be enabled on the page. We'll look at improving our documentation to better describe things.

straker avatar Jun 17 '22 14:06 straker

As we are running javascript enabled scripts, issue trying is expected.

padmavemulapati avatar Jul 20 '22 14:07 padmavemulapati

Validated with the latest axe-core/puppeteer@ 4.5.3-alpha.357 and [email protected] , with the caveat, await page.setJavaScriptEnabled(false); we are unable to do execution.

Image

Enhancement suggested: It is good if it display any warning message and quit from the execution

padmavemulapati avatar Dec 21 '22 11:12 padmavemulapati