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

improve the error when one uses Action.Do directly instead of Run #326

Open
mvdan opened this issue Apr 30, 2019 · 8 comments
Open

improve the error when one uses Action.Do directly instead of Run #326

mvdan opened this issue Apr 30, 2019 · 8 comments

Comments

@mvdan
Copy link
Contributor

mvdan commented Apr 30, 2019

Right now, it just errors with "invalid context", which is confusing and not helpful.

@mvdan mvdan added this to the v0.3.0 milestone Apr 30, 2019
@mvdan mvdan removed this from the v0.3.0 milestone May 8, 2019
@mvdan
Copy link
Contributor Author

mvdan commented May 24, 2019

If anyone encounters this error, you probably want to do:

c := chromedp.FromContext(ctx)
action.Do(cdp.WithExecutor(ctx, c.Target))

We might make this unnecessary at some point.

@Northern-Lights
Copy link

The following seems to work (cdp package instead of cdproto):

c := chromedp.FromContext(ctx)
action.Do(cdp.WithExecutor(ctx, c.Target))

@mvdan
Copy link
Contributor Author

mvdan commented Jun 13, 2019

Indeed, I mixed up the package. Will edit my comment just in case.

@kenshaw
Copy link
Member

kenshaw commented Jun 18, 2019

Better errors should be propagated in the next version of chromedp, instead of context canceled. This has necessitated some major internal rework, but I'm fairly confident that when the browser dies (or closes the connection to cdp), that the changes I've made will propagate this back in a clearer fashion.

@kenshaw kenshaw added this to the v0.4.0 milestone Jul 2, 2019
@mvdan mvdan removed this from the v0.5.0 milestone Nov 14, 2019
@slealq
Copy link

slealq commented Dec 24, 2019

Could this be used inside a ListenTarget callback?

@rcmonitor
Copy link

rcmonitor commented Dec 8, 2020

Could this be used inside a ListenTarget callback?

+1 on this question
i.e., Where do I get an action from inside ListenTarget?

@PickledFish
Copy link

Could this be used inside a ListenTarget callback?

+1 on this question
i.e., Where do I get an action from inside ListenTarget?

Did you solve this problem? I have the same problem as you.

@ZekeLu
Copy link
Member

ZekeLu commented May 13, 2021

Could this be used inside a ListenTarget callback?

Yes.

i.e., Where do I get an action from inside ListenTarget?

Is it a typo? The action is the one you want to execute. For example, network.GetAllCookies(), page.PrintToPDF(), etc.

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

8 participants
@ZekeLu @kenshaw @mvdan @Northern-Lights @rcmonitor @slealq @PickledFish and others