feat: add PromoteToInteractive and DemoteToDocument for mid-session page transfer
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:
10
document.go
10
document.go
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user