{"record":{"id":"eaca255ebdac9930","repo":"projectdiscovery/katana","slug":"could-not-get-buttons","errorCode":null,"errorMessage":"could not get buttons","messagePattern":"could not get buttons","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/engine/headless/browser/element.go","lineNumber":91,"sourceCode":"\t\t\t// TODO: Check if this button is already in the unique map\n\t\t\t// and if so remove it\n\t\t\tunique[element.Hash()] = struct{}{}\n\t\t}\n\t\thash := form.Hash()\n\t\tif _, found := unique[hash]; found {\n\t\t\tcontinue\n\t\t}\n\t\tunique[hash] = struct{}{}\n\n\t\tnavigations = append(navigations, &types.Action{\n\t\t\tType: types.ActionTypeFillForm,\n\t\t\tForm: form,\n\t\t})\n\t}\n\n\tbuttons, err := b.GetAllElements(buttonsCSSSelector)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"could not get buttons\")\n\t}\n\tfor _, button := range buttons {\n\t\tif isElementDisabled(button) {\n\t\t\tcontinue\n\t\t}\n\n\t\thash := button.Hash()\n\t\tbutton.MD5Hash = hash\n\n\t\tif _, found := unique[hash]; found {\n\t\t\tcontinue\n\t\t}\n\t\tunique[hash] = struct{}{}\n\t\tnavigations = append(navigations, &types.Action{\n\t\t\tType:    types.ActionTypeLeftClick,\n\t\t\tElement: button,\n\t\t})\n\t}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/projectdiscovery/katana/blob/e3e742739c3746f085943ce918fb4e2b8daf6fe6/pkg/engine/headless/browser/element.go#L73-L109","documentation":"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.","triggerScenarios":"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.","commonSituations":"Crawling pages with rapid client-side redirects; heavy multi-tab crawling where renderers get killed; older katana builds with flaky eval marshaling.","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"],"exampleFix":"// before\nbuttons, err := page.FindNavigations()\nif err != nil { return fmt.Errorf(\"crawl failed: %w\", err) }\n// after\nbuttons, err := page.FindNavigations()\nif err != nil {\n    logger.Warn(\"skipping page: button discovery failed\", slog.String(\"error\", err.Error()))\n    return nil\n}","handlingStrategy":"retry","validationCode":"// selector and page readiness check before eval\nif err := page.WaitLoad(); err != nil { return retry }","typeGuard":"func hasButtons(p *browser.BrowserPage) bool {\n    els, err := p.GetAllElements(\"button\")\n    return err == nil && len(els) >= 0 // err==nil proves eval health\n}","tryCatchPattern":"navs, err := page.FindNavigations()\nif err != nil {\n    logger.Debug(\"button discovery failed\", slog.String(\"error\", err.Error()))\n    return retryOrSkip(page)\n}","preventionTips":["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"],"tags":["headless-browser","cdp-eval","crawl"],"backgroundTag":"cdp-evaluation-failed","analyzedSha":"e3e742739c3746f085943ce918fb4e2b8daf6fe6","analyzedAt":"2026-09-03T14:55:13.248Z","contentChangedAt":"2026-09-03T14:55:13.248Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}