From 8ee98c3fa14c5d3af70a79fd7515e76f709e4c9c Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 1 Apr 2024 10:21:10 -0700 Subject: [PATCH] docs(java): add BrowserContext.backgroundPage(s) Refereence https://github.com/microsoft/playwright-java/issues/1530 --- docs/src/api/class-browsercontext.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.md index 54884fbd59..7d17bba0fb 100644 --- a/docs/src/api/class-browsercontext.md +++ b/docs/src/api/class-browsercontext.md @@ -64,7 +64,7 @@ await context.CloseAsync(); ## event: BrowserContext.backgroundPage * since: v1.11 -* langs: js, python +* langs: js, python, java - argument: <[Page]> :::note @@ -73,6 +73,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'); ``` @@ -441,7 +448,7 @@ Script to be evaluated in all pages in the browser context. Optional. ## method: BrowserContext.backgroundPages * since: v1.11 -* langs: js, python +* langs: js, python, java - returns: <[Array]<[Page]>> :::note