projectdiscovery/katana · error
could not get buttons
Error message
could not get buttons
What it means
Wrapper error from FindNavigations raised when b.GetAllElements(buttonsCSSSelector) fails while collecting buttons/inputs matching "button, input[type='button'], input[type='submit']". The selector is evaluated in-page via window.getAllElements; a failure is a CDP eval error or a JSON unmarshal error of the element list. It stops button discovery for the page.
Source
Thrown at pkg/engine/headless/browser/element.go:91
// TODO: Check if this button is already in the unique map
// and if so remove it
unique[element.Hash()] = struct{}{}
}
hash := form.Hash()
if _, found := unique[hash]; found {
continue
}
unique[hash] = struct{}{}
navigations = append(navigations, &types.Action{
Type: types.ActionTypeFillForm,
Form: form,
})
}
buttons, err := b.GetAllElements(buttonsCSSSelector)
if err != nil {
return nil, errors.Wrap(err, "could not get buttons")
}
for _, button := range buttons {
if isElementDisabled(button) {
continue
}
hash := button.Hash()
button.MD5Hash = hash
if _, found := unique[hash]; found {
continue
}
unique[hash] = struct{}{}
navigations = append(navigations, &types.Action{
Type: types.ActionTypeLeftClick,
Element: button,
})
}View on GitHub (pinned to e3e742739c)
Solutions
- Wait for page load (page.WaitLoad / WaitPageLoadHeuristics) before calling FindNavigations
- Retry the page; CDP context-destroyed errors are transient
- Verify the browser process is healthy and increase headless memory limits
- Skip the page on this error (log and continue) since crawl resilience matters more than a single page
Example fix
// before
buttons, err := page.FindNavigations()
if err != nil { return fmt.Errorf("crawl failed: %w", err) }
// after
buttons, err := page.FindNavigations()
if err != nil {
logger.Warn("skipping page: button discovery failed", slog.String("error", err.Error()))
return nil
} Defensive patterns
Strategy: retry
Validate before calling
// selector and page readiness check before eval
if err := page.WaitLoad(); err != nil { return retry } Type guard
func hasButtons(p *browser.BrowserPage) bool {
els, err := p.GetAllElements("button")
return err == nil && len(els) >= 0 // err==nil proves eval health
} Try / catch
navs, err := page.FindNavigations()
if err != nil {
logger.Debug("button discovery failed", slog.String("error", err.Error()))
return retryOrSkip(page)
} Prevention
- Wait for page load before discovery
- Retry once on eval errors (context races are transient)
- Monitor browser process health in long crawls
- Treat per-page failures as non-fatal
When it happens
Trigger: 1) Page navigated or execution context destroyed between the forms and buttons steps. 2) Tab crashed/closed. 3) window.getAllElements helper not injected into this document. 4) Unmarshal failure of the returned element array.
Common situations: Crawling pages with rapid client-side redirects; heavy multi-tab crawling where renderers get killed; older katana builds with flaky eval marshaling.
Related errors
- could not get forms
- could not get links
- could not get page info
- could not get event listeners
- could not get page state
AI-assisted analysis of projectdiscovery/katana@e3e742739c (2026-09-03).
Data as JSON: /api/errors/eaca255ebdac9930.
Report an issue: GitHub.