From f5d105f2cc5ec3e8a0dbec3d60a51c454d46c118 Mon Sep 17 00:00:00 2001 From: "daniel_fillol@hotmail.com" <55287657+DanielFillol@users.noreply.github.com> Date: Fri, 12 Jul 2024 17:31:57 -0300 Subject: [PATCH] feat: add nav log to SwitchToFrame and SwitchToDefaultContent --- goSpider.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/goSpider.go b/goSpider.go index 630dbb3..3df36f3 100644 --- a/goSpider.go +++ b/goSpider.go @@ -116,6 +116,8 @@ func (nav *Navigator) GetElementAttribute(selector, attribute string) (string, e // SwitchToFrame switches the context to the specified iframe. func (nav *Navigator) SwitchToFrame(selector string) error { + nav.Logger.Println("Switching to frame", selector) + // Wait for the iframe to be visible err := nav.WaitForElement(selector, nav.Timeout) if err != nil { @@ -139,11 +141,13 @@ func (nav *Navigator) SwitchToFrame(selector string) error { return fmt.Errorf("failed to switch to iframe: %v", err) } + nav.Logger.Println("SwitchToFrame", selector, "successfully") return nil } // SwitchToDefaultContent switches the context back to the main content from an iframe context. func (nav *Navigator) SwitchToDefaultContent() error { + nav.Logger.Println("Switching to default content") // Switch back to the main content err := chromedp.Run(nav.Ctx, chromedp.Tasks{ @@ -161,6 +165,7 @@ func (nav *Navigator) SwitchToDefaultContent() error { return fmt.Errorf("failed to switch to default content: %v", err) } + nav.Logger.Println("Switch to default content successfully") return nil }