Skip to content

Troubleshooting

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.

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.

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.

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 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 in the discussions of chromedp. Give a short program that shows the problem.