After upgrading from v8 to v9, I encountered an issue with file uploads in headless mode. The code worked fine in non-headless mode, but failed in headless mode. I would appreciate any assistance with this.
capabilities: [
{
maxInstances: 1,
browserName: 'chrome',
acceptInsecureCerts: true,
'goog:chromeOptions': {
args: [
'headless', 'disable-gpu',
'--window-size=1920,1080'
],
},
},
Code:
async uploadFile(file) {
const filePath = path.join(process.cwd(), DEFAULT_FILEPATH, file);
console.debug("File path: ", filePath);
const remoteFilePath = await browser.uploadFile(filePath);
await fileuploadPage.inputFileUpload.setValue(remoteFilePath);
await fileuploadPage.submitButton.click();
}
log:
[0-0] RUNNING in chrome - file:///src/test/specs/sanitySuite/test.dscreation.sanity.js
[0-0] File path: /home/mahadev/Desktop/WDIO_V9_upgrade/ui_automation/src/utilities/files/Reorder.csv
[0-0] Error in "Mammoth Data Source Creation Sanity Tests.File upload @sanity"
Error: The uploadFile command is not available in chrome-headless-shell
at async Utils.uploadFile (file:///home/mahadev/Desktop/WDIO_V9_upgrade/ui_automation/src/utilities/utils.js:63:32)
at async Context.<anonymous> (file:///home/mahadev/Desktop/WDIO_V9_upgrade/ui_automation/src/test/specs/sanitySuite/test.dscreation.sanity.js:98:9)
[0-0] FAILED in chrome - file:///src/test/specs/sanitySuite/test.dscreation.sanity.js
"spec" Reporter:
------------------------------------------------------------------
[chrome-headless-shell 126.0.6478.126 linux #0-0] Running: chrome-headless-shell (v126.0.6478.126) on linux
[chrome-headless-shell 126.0.6478.126 linux #0-0] Session ID: 5b0e1cf78bc61aeeb43979a0a73bc7f6
[chrome-headless-shell 126.0.6478.126 linux #0-0]
[chrome-headless-shell 126.0.6478.126 linux #0-0] » /src/test/specs/sanitySuite/test.dscreation.sanity.js
[chrome-headless-shell 126.0.6478.126 linux #0-0] Mammoth Data Source Creation Sanity Tests
[chrome-headless-shell 126.0.6478.126 linux #0-0] ✖ File upload @sanity
[chrome-headless-shell 126.0.6478.126 linux #0-0]
[chrome-headless-shell 126.0.6478.126 linux #0-0] 1 failing (14.8s)
[chrome-headless-shell 126.0.6478.126 linux #0-0]
[chrome-headless-shell 126.0.6478.126 linux #0-0] 1) Mammoth Data Source Creation Sanity Tests File upload @sanity
[chrome-headless-shell 126.0.6478.126 linux #0-0] The uploadFile command is not available in chrome-headless-shell
[chrome-headless-shell 126.0.6478.126 linux #0-0] Error: The uploadFile command is not available in chrome-headless-shell