0

Recently I have updated from v8 to v9, and file upload was working fine in non-headless mode. But the same code fails in headless mode. It would be good, if anyone help on 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

1 Answer 1

0

I am able to upload file without using uploadfile()

    async uploadFile(file){
        const filePath = path.join(process.cwd(), DEFAULT_FILEPATH, file);
        console.debug(`File path: ${filePath}`);
        await fileuploadPage.inputFileUpload.addValue(filePath);
        await fileuploadPage.submitButton.click();
    }

also same question is there on github

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.