Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to get computed style of the page before analysing? #672

Open
rabbit0v0 opened this issue Feb 22, 2023 · 3 comments
Open

Possible to get computed style of the page before analysing? #672

rabbit0v0 opened this issue Feb 22, 2023 · 3 comments

Comments

@rabbit0v0
Copy link

Product: react

Expectation: Do accessibility test with the actual color of the whole page.

Actual: Getting the colors in css instead of the actual color on screen, leading to false negative result.

Motivation: To get computed style when testing in high contrast mode.


@axe-core/playwright: "4.4.5"

@straker
Copy link
Contributor

straker commented Feb 22, 2023

Thanks for the issue. Can you provide a url to the website this occurs on or some sample code that reproduces the issue? Without that I'm not sure there's much we can do.

@rabbit0v0
Copy link
Author

Thanks for the reply!

For now we set high contrast mode with
await page.emulateMedia({ media: "screen", forcedColors: "active", colorScheme: "light" }); ,
and we are doing accessibility test with
const results = await new AxeBuilder({ page }).analyze();
We are not passing the test with this violation below,

"failureSummary": "Fix any of the following:
+ Element has insufficient color contrast of 1.07 (foreground color: #ffff00, background color: #ffffff, font size: 9.0pt (12px), font weight: normal). Expected contrast ratio of 4.5:1",
+ "html": "First name is a required field.",

A screenshot of the span is here.
image

The test fails because it retrieves the color from the css file where the color is set to yellow
image

We wonder if there could be a way to test the actual color from the screen instead of just checking the color in css file :) Many thanks!

@straker
Copy link
Contributor

straker commented Mar 7, 2023

Thanks for the detailed response. I'm not sure there's much we can do. Axe gets the styles directly from window.getComputedStyles. It seems that puppeteer is not setting that when doing emulate media, but there isn't any other way we could read it. I can do some investigating and let you know what I find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants