docs: remove the networkidle mentions (#22906)
Fixes https://github.com/microsoft/playwright/issues/22897
This commit is contained in:
parent
2704601d0c
commit
2ead6e530f
|
|
@ -23,7 +23,6 @@ events:
|
||||||
- page executes some scripts and loads resources like stylesheets and images
|
- page executes some scripts and loads resources like stylesheets and images
|
||||||
- [`event: Page.load`] event is fired
|
- [`event: Page.load`] event is fired
|
||||||
- page executes dynamically loaded scripts
|
- page executes dynamically loaded scripts
|
||||||
- `networkidle` is fired when no new network requests are made for 500 ms
|
|
||||||
|
|
||||||
## Scenarios initiated by browser UI
|
## Scenarios initiated by browser UI
|
||||||
|
|
||||||
|
|
@ -59,36 +58,6 @@ page.goto("https://example.com")
|
||||||
await page.GotoAsync("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
|
### Wait for element
|
||||||
|
|
||||||
In lazy-loaded pages, it can be useful to wait until an element is visible with [`method: Locator.waitFor`].
|
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");
|
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
|
### Wait for element
|
||||||
|
|
||||||
In lazy-loaded pages, it can be useful to wait until an element is visible with [`method: Locator.waitFor`].
|
In lazy-loaded pages, it can be useful to wait until an element is visible with [`method: Locator.waitFor`].
|
||||||
|
|
|
||||||
|
|
@ -145,21 +145,3 @@ it('should check the box using setChecked', async ({ page }) => {
|
||||||
await page.setChecked('input', false);
|
await page.setChecked('input', false);
|
||||||
expect(await page.evaluate(() => window['checkbox'].checked)).toBe(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']);
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -201,3 +201,21 @@ it('should use object previews for errors', async ({ page, browserName }) => {
|
||||||
if (browserName === 'firefox')
|
if (browserName === 'firefox')
|
||||||
expect(text).toEqual('Error');
|
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']);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue