You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/site/docs/en/integrate-with-playwright.mdx
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -267,14 +267,18 @@ After the command executes successfully, it will output: `Midscene - report file
267
267
268
268
Each Agent instance is bound to a single page. To make debugging easier, Midscene intercepts new tabs by default (for example, links with `target="_blank"`) and opens them in the current page.
269
269
270
-
If you want to restore opening in a new tab, set `forceSameTabNavigation` to `false`—but you’ll need to create a new Agent instance for each new tab.
270
+
If you want to restore opening in a new tab while keeping the Agent on the original page, set `forceSameTabNavigation` to `false` and create a new Agent instance for each new tab yourself.
271
+
272
+
If subsequent actions should automatically continue in the newly opened tab, use `PlaywrightBrowserAgent` and enable `autoFollowNewPage`.
Use `PlaywrightBrowserAgent.create(context, options)` only when you do not already have a page. The factory uses `initialPage` when provided, otherwise it reuses the first existing context page or creates a new page.
281
+
278
282
### Connect Midscene Agent to a Remote Playwright Browser
Copy file name to clipboardExpand all lines: apps/site/docs/en/integrate-with-puppeteer.mdx
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,14 +106,18 @@ After the above command executes successfully, the console will output: `Midscen
106
106
107
107
Each Agent instance is bound to a single page. For easier debugging, Midscene intercepts new tabs by default (for example, links with `target="_blank"`) and opens them in the current page.
108
108
109
-
If you want to allow new tabs again, set `forceSameTabNavigation` to `false`—but you must create a new Agent instance for each new tab.
109
+
If you want to allow new tabs again while keeping the Agent on the original page, set `forceSameTabNavigation` to `false` and create a new Agent instance for each new tab yourself.
110
+
111
+
If subsequent actions should automatically continue in the newly opened tab, use `PuppeteerBrowserAgent` and enable `autoFollowNewPage`.
Use `PuppeteerBrowserAgent.create(browser, options)` only when you do not already have a page. The factory uses `initialPage` when provided, otherwise it reuses the first existing browser page or creates a new page.
120
+
117
121
### Connect Midscene Agent to a Remote Puppeteer Browser
Copy file name to clipboardExpand all lines: apps/site/docs/en/web-api-reference.mdx
+38-2Lines changed: 38 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,11 +56,29 @@ In addition to the base agent options, Puppeteer exposes:
56
56
57
57
:::info
58
58
59
-
- One agent per page: by default (`forceSameTabNavigation: true`), Midscene opens new links in the current tab for easier debugging. Set it to `false` if you want new tabs, and create a new agent per tab.
59
+
- One agent per page: by default (`forceSameTabNavigation: true`), Midscene opens new links in the current tab for easier debugging. Set it to `false` if you want normal new-tab behavior and create a new `PuppeteerAgent` for each page yourself. Use `PuppeteerBrowserAgent` when the same Agent should manage browser-level page switching.
60
60
- For the full list of interaction methods, see [API reference (Common)](./api#interaction-methods).
61
61
62
62
:::
63
63
64
+
### Browser agent
65
+
66
+
Use `PuppeteerBrowserAgent` when one Midscene Agent should manage page switching inside a Puppeteer browser.
- Constructor: `new PuppeteerBrowserAgent(browser, page, options?)`— Use this when you already have the initial page.
75
+
- Factory: `PuppeteerBrowserAgent.create(browser, options?)`— Use this when you do not already have a page. It uses `initialPage` if provided, otherwise the first existing browser page, or creates a new page.
76
+
-`initialPage: Page`— Initial Puppeteer page for the factory.
77
+
-`autoFollowNewPage: boolean`— Automatically switch the active page when the browser opens a new page. Default `false`.
78
+
-`newPageTimeout: number`— Timeout for `waitForNewPage`. Default `5000`.
79
+
-`setActivePage(page: Page)`— Explicitly set which Puppeteer page the Browser Agent controls next.
80
+
-`waitForNewPage(action?, options?)`— Wait for a newly opened page without implicitly switching the active page.
81
+
64
82
### Examples
65
83
66
84
#### Quick start
@@ -143,11 +161,29 @@ const agent = new PlaywrightAgent(page, {
143
161
144
162
:::info
145
163
146
-
- One agent per page: with `forceSameTabNavigation` (default `true`), Midscene intercepts new tabs for stability. Set it to `false` to allow new tabs and create a separate agent for each.
164
+
- One agent per page: with `forceSameTabNavigation` (default `true`), Midscene intercepts new tabs for stability. Set it to `false` to allow normal new tabs and create a new `PlaywrightAgent` for each page yourself. Use `PlaywrightBrowserAgent` when the same Agent should manage browser-context-level page switching.
147
165
- For the full list of interaction methods, see [API reference (Common)](./api#interaction-methods).
148
166
149
167
:::
150
168
169
+
### Browser agent
170
+
171
+
Use `PlaywrightBrowserAgent` when one Midscene Agent should manage page switching inside a Playwright browser context.
- Constructor: `new PlaywrightBrowserAgent(context, page, options?)`— Use this when you already have the initial page.
180
+
- Factory: `PlaywrightBrowserAgent.create(context, options?)`— Use this when you do not already have a page. It uses `initialPage` if provided, otherwise the first existing context page, or creates a new page.
181
+
-`initialPage: Page`— Initial Playwright page for the factory.
182
+
-`autoFollowNewPage: boolean`— Automatically switch the active page when the context opens a new page. Default `false`.
183
+
-`newPageTimeout: number`— Timeout for `waitForNewPage`. Default `5000`.
184
+
-`setActivePage(page: Page)`— Explicitly set which Playwright page the Browser Agent controls next.
185
+
-`waitForNewPage(action?, options?)`— Wait for a newly opened page without implicitly switching the active page.
`[midscene:error] forceChromeSelectRendering requires ${config.displayName}${config.requirementLabel}, but current version is ${version}. This feature may not work correctly.`,
0 commit comments