Aller au contenu

noPlaywrightWaitForSelector

Ce contenu n’est pas encore disponible dans votre langue.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noPlaywrightWaitForSelector": "error"
}
}
}
}

Disallow using page.waitForSelector().

Playwright’s page.waitForSelector() is discouraged in favor of more reliable locator-based APIs. Using locators with assertions or actions automatically waits for elements to be ready.

await page.waitForSelector('.submit-button');
code-block.js:1:7 lint/nursery/noPlaywrightWaitForSelector  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Unexpected use of page.waitForSelector().

> 1 │ await page.waitForSelector(‘.submit-button’);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

Locators automatically wait for elements to be ready, making explicit waits unnecessary.

Use locator-based page.locator() or page.getByRole() APIs instead.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

Unsafe fix: Replace with locator(selector).waitFor().

1 - await·page.waitForSelector(.submit-button);
1+ await·page.locator(.submit-button).waitFor();
2 2

await page.waitForSelector('#dialog', { state: 'visible' });
await page.click('#dialog .button');
code-block.js:1:7 lint/nursery/noPlaywrightWaitForSelector  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Unexpected use of page.waitForSelector().

> 1 │ await page.waitForSelector(‘#dialog’, { state: ‘visible’ });
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │ await page.click(‘#dialog .button’);
3 │

Locators automatically wait for elements to be ready, making explicit waits unnecessary.

Use locator-based page.locator() or page.getByRole() APIs instead.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

Unsafe fix: Replace with locator(selector).waitFor().

1 - await·page.waitForSelector(#dialog,·{·state:·visible·});
1+ await·page.locator(#dialog).waitFor({·state:·visible·});
2 2 await page.click(‘#dialog .button’);
3 3

await page.locator('.submit-button').click();
await expect(page.locator('#dialog')).toBeVisible();
const button = page.getByRole('button', { name: 'Submit' });
await button.click();