Skip to content

Commit ec2579c

Browse files
committed
Fix amOnPage auto-initialization with BROWSER_RESTART=browser
- Allow auto-initialization when manualStart is false - Prevents 'Cannot navigate: browser is not running' error - Fixes issue where Before() hooks run before _before() in restart=browser mode - Only block navigation when manualStart is explicitly enabled
1 parent 48a7ddf commit ec2579c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/helper/Playwright.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,8 +1503,9 @@ class Playwright extends Helper {
15031503
throw new Error('Cannot open pages inside an Electron container')
15041504
}
15051505

1506-
// Prevent navigation attempts when browser is being torn down
1507-
if (!this.isRunning && (!this.browser || !this.browserContext || !this.page)) {
1506+
// Prevent navigation attempts only when manual start is enabled and browser is not running
1507+
// Allow auto-initialization for normal operation (e.g., when using BROWSER_RESTART=browser)
1508+
if (!this.isRunning && this.options.manualStart && (!this.browser || !this.browserContext || !this.page)) {
15081509
throw new Error('Cannot navigate: browser is not running or has been closed')
15091510
}
15101511

0 commit comments

Comments
 (0)