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);错误日志:
./test/support/data/BestInterestAdviceModel.pdf脚本在本地执行中工作,而File实验室中的
脚本出现故障(铬79.0.3945.79 Windows #0-0无效参数:文件未找到:(会话信息: chrome=79.0.3945.79) (驱动程序信息: chromedriver=79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614}),)./test/support/data/BestInterestAdviceModel.pdf NT 10.0.10586 Windows #05.79 platform=Windows 79.0.3945.79 Windows #0-0错误:无效参数:文件未找到:platform=Windows chrome 79.0.3945.79 Windows #0-0 chrome 79.0.3945.79 Windows #0-0 endReadableNT 79.0.3945.79 Windows #0-0 at endReadableNT (_stream_readable.js:1064:12) chrome 79.0.3945.79 Windows #0在endReadableNT 79.0.3945.79 Windows#0 at documentUpload (/builds/test-engineering/testing-projects/testing-src/name-src-ips-work-manager/test/support/utils/index.js:78:14)铬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)铬79.0.3945.79 Windows #0在Array.some ()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:52:16)上WizardPage.selectAndUploadForm 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)
发布于 2019-12-31 12:30:58
您不能像在本地机器上一样,在云中上传文件(不管是Sauce实验室还是不同的云供应商)。云VM无法访问本地文件系统。
Sauce实验室与WebdriverIO的结合有两种可能的解决方案。
只有
browser.uploadFile(localPath)你可以在这里查一下,https://github.com/saucelabs-sample-test-frameworks/WebdriverIO-download-upload
注意:您应该想知道是否真的需要通过前端进行文件上传测试。UI测试往往是片状的,而测试文件上传会使它们变得更加古怪。
https://stackoverflow.com/questions/59543743
复制相似问题