Skip to content

Commit

Permalink
docs: update context.backgroundPage event examples (#30210)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s committed Apr 2, 2024
1 parent 4baacba commit 8056e53
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions docs/src/api/class-browsercontext.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ 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();
context.onBackgroundPage(backgroundPage -> {
System.out.println(backgroundPage.url());
});
System.out.println(backgroundPage.evaluate("location.href"));
```

```js
Expand All @@ -92,11 +91,11 @@ background_page = context.wait_for_event("backgroundpage")
```

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

```

## event: BrowserContext.close
Expand Down

0 comments on commit 8056e53

Please sign in to comment.