{"record":{"id":"38cf16c8fbc11105","repo":"grafana/k6","slug":"checking-element-is-disabled-w","errorCode":null,"errorMessage":"checking element is disabled: %w","messagePattern":"checking element is disabled: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1069,"sourceCode":"}\n\n// IsChecked checks if a checkbox or radio is checked.\nfunc (h *ElementHandle) IsChecked() (bool, error) {\n\tok, err := h.isChecked(h.ctx, 0)\n\t// We don't care about timeout errors here!\n\tif err != nil && !errors.Is(err, ErrTimedOut) {\n\t\treturn false, fmt.Errorf(\"checking element is checked: %w\", err)\n\t}\n\n\treturn ok, nil\n}\n\n// IsDisabled checks if the element is disabled.\nfunc (h *ElementHandle) IsDisabled() (bool, error) {\n\tok, err := h.isDisabled(h.ctx, 0)\n\t// We don't care anout timeout errors here!\n\tif err != nil && !errors.Is(err, ErrTimedOut) {\n\t\treturn false, fmt.Errorf(\"checking element is disabled: %w\", err)\n\t}\n\n\treturn ok, nil\n}\n\n// IsEditable checks if the element is editable.\nfunc (h *ElementHandle) IsEditable() (bool, error) {\n\tok, err := h.isEditable(h.ctx, 0)\n\t// We don't care anout timeout errors here!\n\tif err != nil && !errors.Is(err, ErrTimedOut) {\n\t\treturn false, fmt.Errorf(\"checking element is editable: %w\", err)\n\t}\n\n\treturn ok, nil\n}\n\n// IsEnabled checks if the element is enabled.\nfunc (h *ElementHandle) IsEnabled() (bool, error) {","sourceCodeStart":1051,"sourceCodeEnd":1087,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L1051-L1087","documentation":"Returned by ElementHandle.isDisabled() when the state probe fails with a non-timeout error. Timeouts are intentionally swallowed (a timeout merely means the element is not disabled yet); the remaining causes are a stale/detached handle, a destroyed execution context, a CDP transport failure, or a closed page/browser.","triggerScenarios":"Calling isDisabled() on a handle detached by a DOM re-render; after a navigation destroyed the context; after the page or browser was closed; a dropped CDP session.","commonSituations":"Reusing handles across iterations in SPAs that re-render controls; probing disabled state right after an action that navigates; end-of-scenario teardown races.","solutions":["Re-query the handle right before isDisabled()","Wait for the element to be attached first","Confirm the page is still open before probing","Catch and distinguish hard errors from a legitimate false return"],"exampleFix":"// before\nconst disabled = await h.isDisabled(); // stale handle\n// after\nconst el = await page.$('#submit');\nconst disabled = await el.isDisabled();","handlingStrategy":"try-catch","validationCode":"const el = await page.$('#submit');\nif (el && (await el.isVisible())) {\n  const disabled = await el.isDisabled();\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await handle.isDisabled();\n} catch (e) {\n  if (String(e).includes('checking element is disabled')) {\n    const fresh = await page.$(sel);\n    return fresh ? fresh.isDisabled() : true;\n  }\n  throw e;\n}","preventionTips":["A false return is a valid answer; only thrown errors indicate operational failure","Re-query handles before state probes in re-rendering pages","Avoid probing after navigation or page close"],"tags":["browser","element-handle","is-disabled","detached-handle"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}