我想使用testcafe. 它有几个步骤来上传文件。
在 HTML 代码中,输入 [type=file] 是隐藏的。HTML代码:
<div class="col-md-12">
<input type="button" class="btn btn-primary btn-exec" value="Select Files" id="fileBrowseBtn">
<input type="file" id="selectFiles" webkitdirectory="" style="display: none">
</div>
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下代码,但根本不起作用。
await t
.click(Selector('#fileBrowseBtn'))
.setNativeDialogHandler(() => true)
.setFilesToUpload(Selector('input').withAttribute('type','file'), [
'./uploads/1.jpg',
'./uploads/2.jpg',
'./uploads/3.jpg'
])
.setNativeDialogHandler(() => true)
.click(Selector('#uploadWizard').find('button').withText('Upload'))
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我提供可行的例子吗?我尝试了很多,但可能是我错过了一些东西。提前致谢。
javascript file-upload multifile-uploader e2e-testing testcafe