Skip to content

Commit 7748e21

Browse files
committed
cherry-pick(#30210): docs: update context.backgroundPage event examples
1 parent acb6ff1 commit 7748e21

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

docs/src/api/class-browsercontext.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,9 @@ Only works with Chromium browser's persistent context.
7373
Emitted when new background page is created in the context.
7474

7575
```java
76-
Page backgroundPage = context.waitForBackgroundPage(() -> {
77-
page.getByText("activate extension").click();
76+
context.onBackgroundPage(backgroundPage -> {
77+
System.out.println(backgroundPage.url());
7878
});
79-
System.out.println(backgroundPage.evaluate("location.href"));
8079
```
8180

8281
```js
@@ -92,11 +91,11 @@ background_page = context.wait_for_event("backgroundpage")
9291
```
9392

9493
```csharp
95-
var backgroundPage = await context.RunAndWaitForBackgoundPageAsync(async =>
94+
context.BackgroundPage += (backgroundPage) =>
9695
{
97-
await page.GetByText("activate extension").ClickAsync();
98-
});
99-
Console.WriteLine(await backgroundPage.EvaluateAsync<string>("location.href"));
96+
Console.WriteLine(backgroundPage.Url());
97+
};
98+
10099
```
101100

102101
## event: BrowserContext.close

0 commit comments

Comments
 (0)