How do I use @axe-core/playwright to fix 'HomePage' object attribute and argument issues in my tests?


To fix 'HomePage' object attribute and argument issues using @axe-core/playwright, follow these steps:

1. Navigate to your site

Use page.goto() to navigate to your site:

await page.goto('https://ray.run/');

2. Create an AxeBuilder instance

Pass {page} as an option:

import { AxeBuilder } from '@axe-core/playwright';

const axeBuilder = new AxeBuilder({ page });

3. Configure the accessibility scan

Use AxeBuilder.include() to constrain the scan to a specific part of the page. For example, to include only the main content area:


4. Interact with the page

Use Locators to interact with the page before invoking analyze(). Make sure to waitFor() the page to be in the desired state before running the analysis.

await page.locator('#some-button').click();
await page.waitForSelector('#some-element');

5. Analyze the page

Call AxeBuilder.analyze() to scan the page in its current state:

const accessibilityScanResults = await axeBuilder.analyze();

6. Check for violations

Assert that there are no violations:

import { test } from '@playwright/test';

test('Accessibility check', async ({ page }) => {
  // ... previous steps ...

By following these steps and using @axe-core/playwright's tools, you can effectively fix 'HomePage' object attribute and argument issues in your tests.

Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.