Troubleshooting
The program cannot find Chrome
Section titled “The program cannot find Chrome”chromedp looks for Chrome in the places that Install
lists. If Chrome is somewhere else, give its path with chromedp.ExecPath. See
Options of the browser.
An action waits for ever
Section titled “An action waits for ever”A query waits until the page has the element, and it waits until the
context ends. Check the selector in the developer tools of Chrome, and set a
timeout on the context, so that the program
stops with an error. To see what the program and the browser say to each
other, add chromedp.WithDebugf(log.Printf) to chromedp.NewContext.
Chrome keeps running after the program
Section titled “Chrome keeps running after the program”Call the cancel function of chromedp.NewContext with defer. A program
that ends with log.Fatal or os.Exit skips its deferred calls, so return
the error from a function, and call log.Fatal only in main, after the
deferred calls of that function have run.
The page looks different in the program
Section titled “The page looks different in the program”Chrome runs headless by default, with a viewport of its own size. Set the
size with chromedp.EmulateViewport, or watch the browser with
chromedp.WithVisibleWindow() or the environment variable
CHROMEDP_VISIBLEWINDOW=1.
A selector finds nothing in an iframe
Section titled “A selector finds nothing in an iframe”A query looks in the document of the page, and an iframe has a document of
its own. Get the node of the iframe first, then query inside it with
chromedp.FromNode. See Selectors and waiting.
Ask a question
Section titled “Ask a question”Ask in the discussions of chromedp. Give a short program that shows the problem.