grafana/k6 · error
non-multiple file input can only accept single file
Error message
non-multiple file input can only accept single file
What it means
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.
Source
Thrown at internal/js/modules/k6/browser/common/element_handle.go:1915
"error:notelement": "node is not an element",
"error:nothtmlelement": "not an HTMLElement",
"error:notfillableelement": "element is not an <input>, <textarea> or [contenteditable] element",
"error:notfillableinputtype": "input of this type cannot be filled",
"error:notfillablenumberinput": "cannot type text into input[type=number]",
"error:notvaliddate": "malformed value",
"error:notinput": "node is not an HTMLInputElement",
"error:notfile": "node is not an input[type=file] element",
"error:hasnovalue": "node is not an HTMLInputElement or HTMLTextAreaElement or HTMLSelectElement",
"error:notselect": "element is not a <select> element",
"error:notcheckbox": "not a checkbox or radio button",
"error:notmultiplefileinput": "non-multiple file input can only accept single file",
"error:strictmodeviolation": "strict mode violation, multiple elements returned for selector query",
"error:notqueryablenode": "node is not queryable",
"error:nthnocapture": "can't query n-th element in a chained selector with capture",
"error:intercept": "another element is intercepting with pointer action",
}
if err, ok := errs[serr]; ok {
return errors.New(err)
}
return errors.New(serr)
}
View on GitHub (pinned to 01ffac6f24)
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
Example fix
// before
await page.setInputFiles('input[type=file]', [fileA, fileB]);
// after (single-file input)
await page.setInputFiles('input[type=file]', fileA); Defensive patterns
Strategy: validation
Validate before calling
// Inspect the input before uploading
const isMultiple = await page.$eval(
'input[type=file]',
el => el.hasAttribute('multiple')
);
const files = isMultiple ? [fileA, fileB] : fileA;
await page.setInputFiles('input[type=file]', files); Try / catch
try {
await handle.setInputFiles(files);
} catch (e) {
if (/single file/.test(e.message)) {
await handle.setInputFiles(files[0]); // retry with one file
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- parsing setInputFiles parameter: %w
- node is not queryable
- parsing setInputFiles options: %w
- parsing setInputFiles parameter: %w
- focusing on element: %w
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/5b304741ced48271.
Report an issue: GitHub.