{"record":{"id":"2ae777cb908fe416","repo":"grafana/k6","slug":"parsing-element-index-q-for-selector-q-w","errorCode":null,"errorMessage":"parsing element index %q for selector %q: %w","messagePattern":"parsing element index %q for selector %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1308,"sourceCode":"\tprops, err := handles.GetProperties()\n\tif err != nil {\n\t\t// GetProperties has a rich error already, so we don't need to wrap it.\n\t\treturn nil, err //nolint:wrapcheck\n\t}\n\n\ttype indexedElem struct {\n\t\tindex int\n\t\telem  *ElementHandle\n\t}\n\n\tindexedElems := make([]indexedElem, 0, len(props))\n\tfor key, prop := range props {\n\t\tif el := prop.AsElement(); el != nil {\n\t\t\t// DOM elements are stored with numeric indices (\"0\", \"1\", \"2\", ...)\n\t\t\t// per JavaScript's array-like object specification.\n\t\t\tidx, err := strconv.Atoi(key)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing element index %q for selector %q: %w\", key, selector, err)\n\t\t\t}\n\t\t\tindexedElems = append(indexedElems, indexedElem{index: idx, elem: el})\n\t\t} else if err := prop.Dispose(); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"disposing property while querying all selectors %q: %w\", selector, err)\n\t\t}\n\t}\n\n\tslices.SortFunc(indexedElems, func(a, b indexedElem) int {\n\t\treturn cmp.Compare(a.index, b.index)\n\t})\n\n\tels := make([]*ElementHandle, 0, len(indexedElems))\n\tfor _, ie := range indexedElems {\n\t\tels = append(els, ie.elem)\n\t}\n\n\treturn els, nil\n}","sourceCodeStart":1290,"sourceCodeEnd":1326,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L1290-L1326","documentation":"While flattening the $$ result, queryAll iterates GetProperties of the array-like handle and expects numeric keys ('0','1',...); strconv.Atoi rejected a key (element_handle.go:1308). Per JavaScript array semantics the keys must be indices, so a non-numeric key means the protocol returned a non-array-like shape — an internal/k6 bug, not user input.","triggerScenarios":"GetProperties returning symbol/named properties or an unexpected object shape from a chromium version deviation; k6 browser-module regression in the $$ plumbing.","commonSituations":"Not seen in normal use; surfaces with unusual chromium builds or module regressions, consistently for the same selector.","solutions":["Upgrade k6 to the latest release","If it persists, file a k6 issue with the minimal selector and chromium version","Work around with page.$$ or frame.$$ on the containing frame","Avoid the affected element.$$ path while the bug is outstanding"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return await el.$$(sel); }\ncatch (e) { if (/parsing element index/.test(e.message)) { return await page.$$(sel); /* fallback path */ } throw e; }","preventionTips":["Treat as an internal bug: update k6, report upstream","Keep a page.$$ fallback for scraping paths"],"tags":["browser","internal","invariant"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}