Alunkan
Alunkan

Reputation: 5

webdrvierIO file uploading is failing in saucelab

WebdrvierIO file uploading is failing ,

code:

const testFilePath = 'C:/Users/num/Downloads/name-src-ips-work-manager-IPSEsignScenarios/name-src-ips-work-manager-IPSEsignScenarios/test/support/data/ClientGeneralAccountAgreement.pdf';
        //const testFilePath = `../support/data/ClientGeneralAccountAgreement.pdf`;
        const fileUpload = $('.form-upload-textbox');
        browser.execute(
            // assign style to elem in the browser
            (el) => el.style.display = 'block',
            // pass in element so we don't need to query it again in the browser
            fileUpload
        );
        fileUpload.waitForDisplayed();

        //const filePath = path.join(__dirname, 'path/to/your/file');
        fileUpload.setValue(testFilePath);

    browser.pause(8000);

Error logs:

script is working in local execution whereas failing in sauce lab [chrome 79.0.3945.79 Windows #0-0] invalid argument: File not found : ./test/support/data/BestInterestAdviceModel.pdf (Session info: chrome=79.0.3945.79) (Driver info: chromedriver=79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614}),platform=Windows NT 10.0.10586 x86_64) [chrome 79.0.3945.79 Windows #0-0] Error: invalid argument: File not found : ./test/support/data/BestInterestAdviceModel.pdf [chrome 79.0.3945.79 Windows #0-0] (Session info: chrome=79.0.3945.79) [chrome 79.0.3945.79 Windows #0-0] (Driver info: chromedriver=79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614}),platform=Windows NT 10.0.10586 x86_64) [chrome 79.0.3945.79 Windows #0-0] at endReadableNT (_stream_readable.js:1064:12) [chrome 79.0.3945.79 Windows #0-0] at [chrome 79.0.3945.79 Windows #0-0] at documentUpload (/builds/test-engineering/testing-projects/testing-src/name-src-ips-work-manager/test/support/utils/index.js:78:14) [chrome 79.0.3945.79 Windows #0-0] at some (/builds/test-engineering/testing-projects/testing-src/name-src-ips-work-manager/test/support/pages/wizardPage.js:54:9) [chrome 79.0.3945.79 Windows #0-0] at Array.some () [chrome 79.0.3945.79 Windows #0-0] at WizardPage.selectAndUploadForm (/builds/test-engineering/testing-projects/testing-src/name-src-ips-work-manager/test/support/pages/wizardPage.js:52:16) [chrome 79.0.3945.79 Windows #0-0] at World. (/builds/test-engineering/testing-projects/testing-src/name-src-ips-work-manager/test/support/step_definitions/common.js:17:20)

Upvotes: 0

Views: 614

Answers (1)

wswebcreation
wswebcreation

Reputation: 2375

You can't upload files in the cloud (doesn't matter if it's Sauce Labs or a different cloud vendor) like you are used to do on your local machine. The cloud VM doesn't have access to your local file system.

There are 2 possible solutions for Sauce Labs in combination with WebdriverIO.

  1. Chrome only: There is a Chrome only solution with browser.uploadFile(localPath)

  2. Pre-run executable: With Sauce Labs you can use a pre-run executable to upload a file to a VM and then use that file to upload in your application.

You can check them here https://github.com/saucelabs-sample-test-frameworks/WebdriverIO-download-upload

NOTE: You should wonder if testing uploading a file is really something you need to do through the frontend. UI tests tend to be flaky and testing file uploads make them even more flaky.

Upvotes: 1

Related Questions