lpelypenko / axe-html-reporter

Creates easy to read HTML file from axe-core® accessibility results object
MIT License
30 stars 22 forks source link

Added an option to support displaying screenshot of the element #17

Open zhenyanghua opened 3 years ago

zhenyanghua commented 3 years ago

Liliia (@lpelypenko), thanks for this useful project, it allows us to generate customized report with the foundation you have built.

One thing we love to have is the ability to display a screenshot of an element that has the violation to the specified rules. Because different clients may use different browser driver, with an option to pass in a custom function that returns the processed screenshots will be ideal for broader adaption.

In our case, with this proposed option, we are able to do this:

 // Axe-core reporting
    const results = await new AxePuppeteer(page).analyze();

    await createHtmlReport({
        results,
        options: {
            screenshotFunction: async selector => await (await page.$(selector))?.screenshot({encoding: 'base64'})
        }
    });

    await browser.close();

Which allows us to display an image like this:

image

lpelypenko commented 3 years ago

Hi @zhenyanghua,

I am so sorry for the delay, I will try to look on how this feature works for me locally this week and release by the weekends.

lpelypenko commented 3 years ago

Hi @zhenyanghua, can you please provide full example of screenshotFunction usage that I can run it locally?

danimalweb commented 10 months ago

I am also interested in this functionality. We need to pass reports back to a Design Team, and without screenshots it's more tricky.

marcusNumminen commented 5 months ago

This for sure would be a great to have