I want to test upload folder/ multiple files using testcafe
. It has couple of steps to upload files.
In the HTML code, input [type=file] is hidden. HTML Code:
<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>
I tried with the following code but was not working at all.
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'))
Can anyone help me with workable example? I tried lots but may be I missed something. Thanks in advance.
According to an example, you should not open the 'Choose file' dialog.
Try to simplify your code as follows:
await t
.setFilesToUpload(Selector('input').withAttribute('type','file'), [
'./uploads/1.jpg',
'./uploads/2.jpg',
'./uploads/3.jpg'
])
.click(Selector('#uploadWizard').find('button').withText('Upload'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With