From 82ff8942a385880af1a1cacb9cda6d8c63c99b01 Mon Sep 17 00:00:00 2001 From: Yad Smood Date: Thu, 3 Mar 2022 11:20:33 +0800 Subject: [PATCH] use element to get the window obj --- page_eval.go | 9 ++------- page_eval_test.go | 3 --- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/page_eval.go b/page_eval.go index 3506859d..5d3900ea 100644 --- a/page_eval.go +++ b/page_eval.go @@ -354,17 +354,12 @@ func (p *Page) getJSCtxID() (proto.RuntimeRemoteObjectID, error) { return *p.jsCtxID, nil } - owner, err := proto.DOMGetFrameOwner{FrameID: p.FrameID}.Call(p) + node, err := p.element.Describe(1, true) if err != nil { return "", err } - node, err := proto.DOMDescribeNode{BackendNodeID: owner.BackendNodeID, Pierce: true}.Call(p) - if err != nil { - return "", err - } - - obj, err := proto.DOMResolveNode{BackendNodeID: node.Node.ContentDocument.BackendNodeID}.Call(p) + obj, err := proto.DOMResolveNode{BackendNodeID: node.ContentDocument.BackendNodeID}.Call(p) if err != nil { return "", err } diff --git a/page_eval_test.go b/page_eval_test.go index d5a8c641..18ac4319 100644 --- a/page_eval_test.go +++ b/page_eval_test.go @@ -70,9 +70,6 @@ func (t T) PageUpdateJSCtxIDErr() { frame := page.MustElement("iframe").MustFrame() - t.mc.stubErr(1, proto.DOMGetFrameOwner{}) - t.Err(frame.Element(`button`)) - frame.MustReload() t.mc.stubErr(1, proto.DOMDescribeNode{}) t.Err(frame.Element(`button`))