docs(locators): fixed a descriptive error about Chaining Locators (#21902)

This commit is contained in:
LongLiveY96 2023-03-24 22:03:48 +08:00 committed by GitHub
parent 86af908fa7
commit 0293c26212
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -989,7 +989,7 @@ Note that the inner locator is matched starting from the outer one, not from the
You can chain methods that create a locator, like [`method: Page.getByText`] or [`method: Locator.getByRole`], to narrow down the search to a particular part of the page.
In this example we first create a locator called product by locating the test id. We then filter by text. We can use the product locator again to get by role of button and click it and then use an assertion to make sure there is only one product with the text "Product 2".
In this example we first create a locator called product by locating its role of `listitem`. We then filter by text. We can use the product locator again to get by role of button and click it and then use an assertion to make sure there is only one product with the text "Product 2".
```js
const product = page.getByRole('listitem').filter({ hasText: 'Product 2' });