WebdrvierIO文件在ucelab中上传失败

问题描述 投票:0回答:1

WebdrvierIO文件上传失败,

代码:

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);

错误日志:

脚本正在本地执行中,而在酱汁实验室中却失败了[chrome 79.0.3945.79 Windows#0-0]无效的参数:找不到文件:./test/support/data/BestInterestAdviceModel.pdf(会议信息:chrome = 79.0.3945.79)(驱动程序信息: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]错误:无效参数:找不到文件:./test/support/data/BestInterestAdviceModel.pdf[chrome 79.0.3945.79 Windows#0-0](会话信息:chrome = 79.0.3945.79)[chrome 79.0.3945.79 Windows#0-0](驱动程序信息:chromedriver = 79.0.3945.36(3582db32b33893869b8c1339e8f4d9ed1816f143-refs / branch-heads / 3945 @ {#614}),平台= Windows NT 10.0.10586 x86_64)[chrome 79.0.3945.79 Windows#0-0]位于endReadableNT(_stream_visible.js:1064:12)[chrome 79.0.3945.79 Windows#0-0]位于[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]在某些地方(/builds/test-engineering/testing-projects/testing-src/name-src-ips-work-manager/test/support/pages/wizardPage.js:54 :9)Array.some()上的[chrome 79.0.3945.79 Windows#0-0][Chrome 79.0.3945.79 Windows#0-0]位于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]。 (/builds/test-engineering/testing-projects/testing-src/name-src-ips-work-manager/test/support/step_definitions/common.js:17:20)

file-upload webdriver-io saucelabs
1个回答
0
投票

您无法像过去在本地计算机上一样在云中上传文件(无论是Sauce Lab还是其他云供应商都没有关系)。云虚拟机无权访问您的本地文件系统。

与WebdriverIO结合,Sauce Labs有2种可能的解决方案。

  1. 仅Chrome浏览器:browser.uploadFile(localPath)

  2. 仅支持Chrome的解决方案
  3. [运行前可执行文件:通过Sauce Labs,您可以使用运行前可执行文件将文件上传到VM,然后使用该文件上传在您的应用程序中。

您可以在这里查看它们https://github.com/saucelabs-sample-test-frameworks/WebdriverIO-download-upload

注意:您应该想知道是否真的需要通过前端测试上传文件。 UI测试往往很不稳定,而测试文件上传会使它们更加不稳定。

© www.soinside.com 2019 - 2024. All rights reserved.