feat: add PromoteToInteractive and DemoteToDocument for mid-session page transfer
Some checks failed
CI / build (pull_request) Successful in 29s
CI / test (pull_request) Successful in 36s
CI / vet (pull_request) Failing after 6m18s

Allow transferring ownership of a Playwright page between Document and
InteractiveBrowser modes without tearing down the browser. This enables
handing a live page to a human (e.g. for captcha solving) and resuming
scraping on the same page afterward.

Closes #76

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-24 02:27:42 +00:00
parent 39371dc261
commit e0da88b9b0
4 changed files with 155 additions and 22 deletions

View File

@@ -22,9 +22,10 @@ type Document interface {
type document struct {
node
pw *playwright.Playwright
browser playwright.Browser
page playwright.Page
pw *playwright.Playwright
browser playwright.Browser
page playwright.Page
detached bool
}
func newDocument(pw *playwright.Playwright, browser playwright.Browser, page playwright.Page) (Document, error) {
@@ -44,6 +45,9 @@ func newDocument(pw *playwright.Playwright, browser playwright.Browser, page pla
return res, nil
}
func (d *document) Close() error {
if d.detached {
return nil
}
return d.page.Close()
}