Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get browser console errors #981

Open
ryooxxx opened this issue Nov 25, 2023 · 4 comments
Open

Get browser console errors #981

ryooxxx opened this issue Nov 25, 2023 · 4 comments
Labels
question Questions related to rod

Comments

@ryooxxx
Copy link

ryooxxx commented Nov 25, 2023

Rod Version: v0.114.5

package main

import (
	"github.com/go-rod/rod"
	"github.com/go-rod/rod/lib/proto"
	"fmt"
	"time"
)

func main() {
	u := "https://ubuntu.com/core"

	page := rod.New().MustConnect().MustPage()

	done := make(chan int)
	go page.EachEvent(func(e *proto.RuntimeConsoleAPICalled) { 
		fmt.Println(page.MustObjectsToJSON(e.Args)) 
		close(done) 
	})() 

	page.Timeout(30 * time.Second).MustNavigate(u).MustWaitNavigation()
}

I would like to get the browser error logs/events such as ERR_NAME_NOT_RESOLVED when browsing URLs with the associated loaded network ressource URL. I can see an issue with the same question here #330, but the code sample above doesn't work. What am I doing wrong ? Thank you !

@ryooxxx ryooxxx added the question Questions related to rod label Nov 25, 2023
@ysmood
Copy link
Collaborator

ysmood commented Nov 25, 2023

too fast to see the log before it closes

@ryooxxx
Copy link
Author

ryooxxx commented Nov 25, 2023

package main

import (
	"github.com/go-rod/rod"
	"github.com/go-rod/rod/lib/proto"
	"fmt"
	"time"
	"log"
)

func main() {
	u := "https://ubuntu.com/core"

	page := rod.New().MustConnect().MustPage()

	done := make(chan int)
	go page.EachEvent(func(e *proto.RuntimeConsoleAPICalled) { 
		fmt.Println(page.MustObjectsToJSON(e.Args)) 
		close(done) 
	})() 

	page.Timeout(30 * time.Second).MustNavigate(u).MustWaitNavigation()

	log.Printf("waiting 10 sec")
	time.Sleep(10 * time.Second)
	log.Printf("finished waiting")
}

Even with delay, I only see the JS console.log. I would like to see the errors and warnings like ERR_NAME_NOT_RESOLVED. How can I do that ? Thank you !

@ysmood
Copy link
Collaborator

ysmood commented Nov 27, 2023

I can't get this error with the code you provide. How to reproduce ERR_NAME_NOT_RESOLVED?

@ryooxxx
Copy link
Author

ryooxxx commented Dec 2, 2023

Thanks for your answer. It was just an example. Here is a real example. The URL https://helpdesk.paessler.com/en/support/home returns all the errors below.

image

How can I get the same console messages with go-rod ?

package main

import (
	"github.com/go-rod/rod"
	"github.com/go-rod/rod/lib/proto"
	"fmt"
	"time"
	"log"
)

func main() {
	u := "https://helpdesk.paessler.com/en/support/home"

	page := rod.New().MustConnect().MustPage()

	done := make(chan int)
	go page.EachEvent(func(e *proto.RuntimeConsoleAPICalled) { 
		fmt.Println(page.MustObjectsToJSON(e.Args)) 
		close(done) 
	})() 

	page.Timeout(30 * time.Second).MustNavigate(u).MustWaitNavigation()

	log.Printf("waiting 10 sec")
	time.Sleep(10 * time.Second)
	log.Printf("finished waiting")
}

Thank you for your time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions related to rod
Projects
None yet
Development

No branches or pull requests

2 participants