Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Commit 5a6bbd0

Browse files
committed
docs(readme): remove misleading, incorrect waitFor example
Closes #238
1 parent 1c7a6a4 commit 5a6bbd0

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ yarn add --dev playwright-testing-library
5151

5252
```js
5353
const {webkit} = require('playwright') // or 'firefox' or 'chromium'
54-
const {getDocument, queries, waitFor} = require('playwright-testing-library')
54+
const {getDocument, queries} = require('playwright-testing-library')
5555

5656
const {getByTestId, getByLabelText} = queries
5757

@@ -60,14 +60,17 @@ const page = await browser.newPage()
6060

6161
// Grab ElementHandle for document
6262
const $document = await getDocument(page)
63+
6364
// Your favorite query methods are available
6465
const $form = await getByTestId($document, 'my-form')
65-
// returned elements are ElementHandles too!
66+
67+
// Returned elements are ElementHandles too!
6668
const $email = await getByLabelText($form, 'Email')
67-
// interact with playwright like usual
69+
70+
// Interact with playwright like usual
6871
await $email.type('[email protected]')
69-
// waiting works too!
70-
await waitFor(() => getByText($document, 'Loading...'))
72+
73+
// ...
7174
```
7275

7376
### 2b. Use _extensions_
@@ -79,14 +82,20 @@ require('playwright-testing-library/extend')
7982
const browser = await webkit.launch()
8083
const page = await browser.newPage()
8184

82-
deCall('editor.action.formatDocument')
83-
// getDocument is added to prototype of Page
84-
// getDocument is added to prototype of Page
85+
// Grab document with `getDocument`, which is added to the prototype of `Paqe`
8586
const $document = await page.getDocument()
86-
// query methods are added directly to prototype of ElementHandle
87+
88+
// Query methods are added directly to prototype of `ElementHandle`
8789
const $form = await $document.getByTestId('my-form')
88-
// destructing works if you explicitly call getQueriesForElement
89-
const {getByText} = $form.getQueriesForElement()
90+
91+
// Scope queries with `getQueriesForElement`
92+
const {getByLabelText} = $form.getQueriesForElement()
93+
94+
const $email = await getByLabelText('Email')
95+
96+
// Interact with Playwright like usual
97+
await $email.type('[email protected]')
98+
9099
// ...
91100
```
92101

0 commit comments

Comments
 (0)