You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sources/k6/next/using-k6-browser/recommended-practices/simulate-user-input-delay.md
+46Lines changed: 46 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,7 @@ In the browser modules there are various asynchronous APIs that can be used to w
41
41
|[page.waitForLoadState](#pagewaitforloadstate)| Waits for the specified page life cycle event. |
42
42
|[page.waitForNavigation](#pagewaitfornavigation)| Waits for the navigation to complete after one starts. |
43
43
|[page.waitForResponse](#pagewaitforresponse)| Wait for an HTTP response that matches the specified URL pattern. |
44
+
|[page.waitForRequest](#pagewaitforrequest)| Wait for an HTTP request that matches the specified URL pattern. |
44
45
|[page.waitForTimeout](#pagewaitfortimeout)| Waits the given time. _Use this instead of `sleep` in your frontend tests_. |
45
46
|[page.waitForURL](#pagewaitforurl)| Wait for the page to navigate to the specified URL. |
46
47
|[locator.waitFor](#locatorwaitfor)| Wait for the element to be in a particular state. |
@@ -277,6 +278,51 @@ export default async function () {
277
278
}
278
279
```
279
280
281
+
### page.waitForRequest
282
+
283
+
[page.waitForRequest](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page/waitforrequest) waits for an HTTP request that matches the specified URL pattern. This method is particularly useful for waiting for requests to be initiated before proceeding with the test, such as verifying that form submissions or API calls are triggered.
'pizza API URL is correct': (r) =>r.url() ==='https://quickpizza.grafana.com/api/pizza',
318
+
'pizza API method is POST': (r) =>r.method() ==='POST',
319
+
});
320
+
} finally {
321
+
awaitpage.close();
322
+
}
323
+
}
324
+
```
325
+
280
326
### page.waitForTimeout
281
327
282
328
[page.waitForTimeout](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page/waitfortimeout) will wait the given amount of time. It's functionally the same as k6's [sleep](#whatissleep), but it's asynchronous, which means it will not block the event loop and allows the background tasks to continue to be worked on.
0 commit comments