Skip to content

Commit acb6ff1

Browse files
committed
cherry-pick(#30200): docs(java,csharp): add BrowserContext.backgroundPage(s)
1 parent 7c7f8ac commit acb6ff1

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

docs/src/api/class-browsercontext.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ await context.CloseAsync();
6464

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

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

7473
Emitted when new background page is created in the context.
7574

75+
```java
76+
Page backgroundPage = context.waitForBackgroundPage(() -> {
77+
page.getByText("activate extension").click();
78+
});
79+
System.out.println(backgroundPage.evaluate("location.href"));
80+
```
81+
7682
```js
7783
const backgroundPage = await context.waitForEvent('backgroundpage');
7884
```
@@ -85,6 +91,14 @@ background_page = await context.wait_for_event("backgroundpage")
8591
background_page = context.wait_for_event("backgroundpage")
8692
```
8793

94+
```csharp
95+
var backgroundPage = await context.RunAndWaitForBackgoundPageAsync(async =>
96+
{
97+
await page.GetByText("activate extension").ClickAsync();
98+
});
99+
Console.WriteLine(await backgroundPage.EvaluateAsync<string>("location.href"));
100+
```
101+
88102
## event: BrowserContext.close
89103
* since: v1.8
90104
- argument: <[BrowserContext]>
@@ -441,7 +455,6 @@ Script to be evaluated in all pages in the browser context. Optional.
441455

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

447460
:::note

0 commit comments

Comments
 (0)