{"record":{"id":"5b304741ced48271","repo":"grafana/k6","slug":"non-multiple-file-input-can-only-accept-single-fil","errorCode":null,"errorMessage":"non-multiple file input can only accept single file","messagePattern":"non-multiple file input can only accept single file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1915,"sourceCode":"\t\t\"error:notelement\":             \"node is not an element\",\n\t\t\"error:nothtmlelement\":         \"not an HTMLElement\",\n\t\t\"error:notfillableelement\":     \"element is not an <input>, <textarea> or [contenteditable] element\",\n\t\t\"error:notfillableinputtype\":   \"input of this type cannot be filled\",\n\t\t\"error:notfillablenumberinput\": \"cannot type text into input[type=number]\",\n\t\t\"error:notvaliddate\":           \"malformed value\",\n\t\t\"error:notinput\":               \"node is not an HTMLInputElement\",\n\t\t\"error:notfile\":                \"node is not an input[type=file] element\",\n\t\t\"error:hasnovalue\":             \"node is not an HTMLInputElement or HTMLTextAreaElement or HTMLSelectElement\",\n\t\t\"error:notselect\":              \"element is not a <select> element\",\n\t\t\"error:notcheckbox\":            \"not a checkbox or radio button\",\n\t\t\"error:notmultiplefileinput\":   \"non-multiple file input can only accept single file\",\n\t\t\"error:strictmodeviolation\":    \"strict mode violation, multiple elements returned for selector query\",\n\t\t\"error:notqueryablenode\":       \"node is not queryable\",\n\t\t\"error:nthnocapture\":           \"can't query n-th element in a chained selector with capture\",\n\t\t\"error:intercept\":              \"another element is intercepting with pointer action\",\n\t}\n\tif err, ok := errs[serr]; ok {\n\t\treturn errors.New(err)\n\t}\n\n\treturn errors.New(serr)\n}\n","sourceCodeStart":1897,"sourceCodeEnd":1920,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/element_handle.go#L1897-L1920","documentation":"This message is produced by errorFromDOMError in k6's browser module (element_handle.go:1896-1916), which translates the injected-script error 'error:notmultiplefileinput' into a readable error. It is thrown by setInputFiles when more than one file is supplied to an <input type=\"file\"> element that does not have the 'multiple' attribute. The DOM input can only hold a single file, so the call is rejected before any upload happens.","triggerScenarios":"Calling handle.setInputFiles([...]) or page.setInputFiles(selector, [...]) with an array of two or more file payloads while the matched element is <input type=\"file\"> without the multiple attribute. Passing a single-element array is fine; two or more payloads triggers it.","commonSituations":"Test scripts written against multi-upload forms reused on single-upload pages (avatar/resume upload); test data generators that always emit arrays; the WuT markup changed and dropped the multiple attribute.","solutions":["Pass a single file payload object (not an array) to the non-multiple input: page.setInputFiles(sel, {name, mimeType, data})","If multiple files are intended, verify the selector targets the actual <input type=\"file\" multiple> element and fix the selector","Branch in the script: read the input's multiple attribute via page.evaluate and send one file or many accordingly","If the WuT is expected to accept many files, fix the page markup rather than the test"],"exampleFix":"// before\nawait page.setInputFiles('input[type=file]', [fileA, fileB]);\n\n// after (single-file input)\nawait page.setInputFiles('input[type=file]', fileA);","handlingStrategy":"validation","validationCode":"// Inspect the input before uploading\nconst isMultiple = await page.$eval(\n  'input[type=file]',\n  el => el.hasAttribute('multiple')\n);\nconst files = isMultiple ? [fileA, fileB] : fileA;\nawait page.setInputFiles('input[type=file]', files);","typeGuard":null,"tryCatchPattern":"try {\n  await handle.setInputFiles(files);\n} catch (e) {\n  if (/single file/.test(e.message)) {\n    await handle.setInputFiles(files[0]); // retry with one file\n  } else throw e;\n}","preventionTips":["Check the input's multiple attribute with $eval before choosing one file or many","Keep test fixtures aware of which upload form they target","Assert on the input element type/attributes in a setup step"],"tags":["browser","file-upload","setinputfiles","dom"],"backgroundTag":"file-input-set-files","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}