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

docs: add warning to locator.all #22537

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
docs: add warning to locator.all
  • Loading branch information
dgozman committed Apr 21, 2023
commit 76c9a3f167f8e08e8182fdb9ca4b6864ddc0f594
8 changes: 7 additions & 1 deletion docs/src/api/class-locator.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ a way to find element(s) on the page at any moment. Locator can be created with
When locator points to a list of elements, returns array of locators, pointing
to respective elements.

Note that [`method: Locator.all`] does not wait for elements to match the locator, and instead immediately returns whatever is present in the page. To avoid flakiness when elements are loaded dynamically, wait for the loading to finish before calling [`method: Locator.all`].
:::note
[`method: Locator.all`] does not wait for elements to match the locator, and instead immediately returns whatever is present in the page.

When the list of elements changes dynamically, [`method: Locator.all`] will produce unpredictable and flaky results.

When the list of elements is stable, but loaded dynamically, wait for the full list to finish loading before calling [`method: Locator.all`].
:::

**Usage**

Expand Down
9 changes: 5 additions & 4 deletions packages/playwright-core/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10203,10 +10203,11 @@ export interface Locator {
/**
* When locator points to a list of elements, returns array of locators, pointing to respective elements.
*
* Note that [locator.all()](https://playwright.dev/docs/api/class-locator#locator-all) does not wait for elements to
* match the locator, and instead immediately returns whatever is present in the page. To avoid flakiness when
* elements are loaded dynamically, wait for the loading to finish before calling
* [locator.all()](https://playwright.dev/docs/api/class-locator#locator-all).
* **NOTE** [locator.all()](https://playwright.dev/docs/api/class-locator#locator-all) does not wait for elements to
* match the locator, and instead immediately returns whatever is present in the page. When the list of elements
* changes dynamically, [locator.all()](https://playwright.dev/docs/api/class-locator#locator-all) will produce
* unpredictable and flaky results. When the list of elements is stable, but loaded dynamically, wait for the full
* list to finish loading before calling [locator.all()](https://playwright.dev/docs/api/class-locator#locator-all).
*
* **Usage**
*
Expand Down