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

Can't subscribe to Runtime.consoleAPICalled event #41

Closed
sandro opened this issue Mar 13, 2017 · 4 comments
Closed

Can't subscribe to Runtime.consoleAPICalled event #41

sandro opened this issue Mar 13, 2017 · 4 comments

Comments

@sandro
Copy link

sandro commented Mar 13, 2017

I have a page with javascript that logs to the console. When I navigate to the page using chromdp with logging enabled, I can see that the Runtime.consoleAPICalled event is being fired. I'd like to subscribe to this event, but my naive approach isn't working. Any tips?

c.Run(ctxt, cdp.ActionFunc(func(z context.Context, h cdptypes.Handler) error {
	ch3 := h.Listen(cdptypes.EventRuntimeConsoleAPICalled)
	go func() {
		x := <-ch3
		fmt.Println("\n\nGOT A THING3", x)
	}()
	return nil
}))
c.Run(ctxt, cdp.Navigate(file))
time.Sleep(time.Second)
@MrSaints
Copy link

MrSaints commented Jun 1, 2017

I'm using Listen as well, and it doesn't look like any events are being fired?

It doesn't look like it's even implemented. See:

func (h *TargetHandler) Listen(eventTypes ...cdp.MethodType) <-chan interface{} {
	return nil
}

@MrSaints
Copy link

MrSaints commented Jun 1, 2017

I've put a pull request in for this (#64).

@pwaller
Copy link

pwaller commented Jun 21, 2017

You might be interested in the discussion in #79. It would be good to know the context you're using the console events in - are you trying to just print them, or react to them in the execution path? If the latter, it is important to understand when and how you want to use the result, so that race conditions (of the form that go build -race cannot find) can be avoided. So if you could provide a real world example of the problem you're trying to solve - it would be very useful for getting the design and usage patterns for Listen correct.

@kenshaw
Copy link
Member

kenshaw commented Jul 1, 2017

This will be fixed in a big rollout coming in the next couple days.

@kenshaw kenshaw closed this as completed Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants