-
Notifications
You must be signed in to change notification settings - Fork 781
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
Testing iframes with Playwright/axe-core #4522
Comments
Thanks for the issue. Unfortunately there are serval reason why an iframe wouldn't be tested. If for some reason axe was prevented from loading into the iframe (for example due to CORS), if the iframe was not fully loaded or even lazy loaded ( You could try adding a wait to the script just to see if allowing the page more time to load fixes the issue. import { timeout } from 'node:timers/promises'
await page.goto('https://your-site.com/')
await setTimeout(5000)
const accessibilityScanResults = await new AxeBuilder({ page }).analyze() |
Thanks for your reply! I am trying to analyze https://cryptpad.fr/code. It is indeed likely the injection is being blocked by security measures. Could you clarify what kind of injection is being performed by axe-core, as the documentation seems to lack detail on this? |
I am getting the same issue for an iFrame in a Salesforce application while using the |
@Billy-Stroud Unfortunately at the moment there isn't a way to get at this information. We're in discussions to see if we could expose the actual error, but it won't be any time soon. As a way to see what's going on, I have this custom script I use to inject axe into each frame on the page. You could try running it on the pages in question and hopefully see the same type of error that @axe-core/playwright would be running into. function inject(doc) {
const script = doc.createElement('script');
script.src = 'https://unpkg.com/axe-core@latest';
doc.body.appendChild(script);
doc.querySelectorAll('iframe, frame').forEach(frame => {
frame.contentDocument && inject(frame.contentDocument)
});
}
inject(document) |
@straker Thank you! That allowed me to see the CORS error. It would definitely be helpful to expose these errors in the future. |
Product
axe-core
Product Version
No response
Latest Version
Issue Description
Expectation
I am working on accessibility testing with Playwright and @axe-core, following the instructions here. My page contains iframes and I would like to scan and analyze the content inside them.
Actual
When scanning the page object as per the instructions, the
incomplete
property of theaccessibilityScanResults
object contains this:The link provided under the helpUrl property says to "Ensure iframe and frame elements contain the axe-core script" but doesn't provide an example of how to achieve that.
How to Reproduce
When testing a page containing an iframe with code provided in the documentation:
const accessibilityScanResults = await new AxeBuilder({ page }).analyze()
the above issue occurs. it does not occur on pages without iframes. It happens even when trying to explicitly include the iframe as per the documentation:
const accessibilityScanResults = await new AxeBuilder({ page }).include('#sbox-iframe').analyze()
Additional context
Any thing else we should know about the issue?
The text was updated successfully, but these errors were encountered: