diff --git a/docs/src/navigations.md b/docs/src/navigations.md index d119e51ead..1f941f42a4 100644 --- a/docs/src/navigations.md +++ b/docs/src/navigations.md @@ -23,7 +23,6 @@ events: - page executes some scripts and loads resources like stylesheets and images - [`event: Page.load`] event is fired - page executes dynamically loaded scripts -- `networkidle` is fired when no new network requests are made for 500 ms ## Scenarios initiated by browser UI @@ -59,36 +58,6 @@ page.goto("https://example.com") await page.GotoAsync("https://example.com"); ``` -### Custom wait - -Override the default behavior to wait until a specific event, like `networkidle`. - -```js -// Navigate and wait until network is idle -await page.goto('https://example.com', { waitUntil: 'networkidle' }); -``` - -```java -// Navigate and wait until network is idle -page.navigate("https://example.com", new Page.NavigateOptions() - .setWaitUntil(WaitUntilState.NETWORKIDLE)); -``` - -```python async -# Navigate and wait until network is idle -await page.goto("https://example.com", wait_until="networkidle") -``` - -```python sync -# Navigate and wait until network is idle -page.goto("https://example.com", wait_until="networkidle") -``` - -```csharp -// Navigate and wait until network is idle -await page.GotoAsync("https://example.com", new() { WaitUntil = WaitUntilState.NetworkIdle }); -``` - ### Wait for element In lazy-loaded pages, it can be useful to wait until an element is visible with [`method: Locator.waitFor`]. @@ -197,35 +166,6 @@ await page.GetByText("Login").ClickAsync(); await page.GetByLabel("User Name").FillAsync("John Doe"); ``` -### Custom wait - -`locator.click` can be combined with [`method: Page.waitForLoadState`] to wait for a loading event. - -```js -await page.getByRole('button').click(); // Click triggers navigation -await page.waitForLoadState('networkidle'); // This resolves after 'networkidle' -``` - -```java -page.locator("button").click(); // Click triggers navigation -page.waitForLoadState(LoadState.NETWORKIDLE); // This resolves after "networkidle" -``` - -```python async -await page.locator("button").click() # Click triggers navigation -await page.wait_for_load_state("networkidle") # This waits for the "networkidle" -``` - -```python sync -page.locator("button").click() # Click triggers navigation -page.wait_for_load_state("networkidle") # This waits for the "networkidle" -``` - -```csharp -await page.Locator("button").ClickAsync(); // Click triggers navigation -await page.WaitForLoadStateAsync(LoadState.NetworkIdle); // This resolves after "networkidle" -``` - ### Wait for element In lazy-loaded pages, it can be useful to wait until an element is visible with [`method: Locator.waitFor`]. diff --git a/tests/page/page-check.spec.ts b/tests/page/page-check.spec.ts index a79b83368b..01b00ddc55 100644 --- a/tests/page/page-check.spec.ts +++ b/tests/page/page-check.spec.ts @@ -145,21 +145,3 @@ it('should check the box using setChecked', async ({ page }) => { await page.setChecked('input', false); expect(await page.evaluate(() => window['checkbox'].checked)).toBe(false); }); - -it('do not update console count on unhandled rejections', async ({ page }) => { - const messages: string[] = []; - const consoleEventListener = m => messages.push(m.text()); - page.addListener('console', consoleEventListener); - - await page.evaluate(() => { - const fail = async () => Promise.reject(new Error('error')); - console.log('begin'); - fail(); - fail(); - fail().catch(() => { - console.log('end'); - }); - }); - - await expect.poll(() => messages).toEqual(['begin', 'end']); -}); diff --git a/tests/page/page-event-console.spec.ts b/tests/page/page-event-console.spec.ts index 7e9d1a9a60..31f84a5045 100644 --- a/tests/page/page-event-console.spec.ts +++ b/tests/page/page-event-console.spec.ts @@ -201,3 +201,21 @@ it('should use object previews for errors', async ({ page, browserName }) => { if (browserName === 'firefox') expect(text).toEqual('Error'); }); + +it('do not update console count on unhandled rejections', async ({ page }) => { + const messages: string[] = []; + const consoleEventListener = m => messages.push(m.text()); + page.addListener('console', consoleEventListener); + + await page.evaluate(() => { + const fail = async () => Promise.reject(new Error('error')); + console.log('begin'); + fail(); + fail(); + fail().catch(() => { + console.log('end'); + }); + }); + + await expect.poll(() => messages).toEqual(['begin', 'end']); +});