Skip to content

Commit

Permalink
cherry-pick(#30200): docs(java,csharp): add BrowserContext.background…
Browse files Browse the repository at this point in the history
…Page(s)
  • Loading branch information
mxschmitt committed Apr 9, 2024
1 parent 7c7f8ac commit acb6ff1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions docs/src/api/class-browsercontext.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ await context.CloseAsync();

## event: BrowserContext.backgroundPage
* since: v1.11
* langs: js, python
- argument: <[Page]>

:::note
Expand All @@ -73,6 +72,13 @@ Only works with Chromium browser's persistent context.

Emitted when new background page is created in the context.

```java
Page backgroundPage = context.waitForBackgroundPage(() -> {
page.getByText("activate extension").click();
});
System.out.println(backgroundPage.evaluate("location.href"));
```

```js
const backgroundPage = await context.waitForEvent('backgroundpage');
```
Expand All @@ -85,6 +91,14 @@ background_page = await context.wait_for_event("backgroundpage")
background_page = context.wait_for_event("backgroundpage")
```

```csharp
var backgroundPage = await context.RunAndWaitForBackgoundPageAsync(async =>
{
await page.GetByText("activate extension").ClickAsync();
});
Console.WriteLine(await backgroundPage.EvaluateAsync<string>("location.href"));
```

## event: BrowserContext.close
* since: v1.8
- argument: <[BrowserContext]>
Expand Down Expand Up @@ -441,7 +455,6 @@ Script to be evaluated in all pages in the browser context. Optional.

## method: BrowserContext.backgroundPages
* since: v1.11
* langs: js, python
- returns: <[Array]<[Page]>>

:::note
Expand Down

0 comments on commit acb6ff1

Please sign in to comment.