Bug
If you try to use FormData when uploading a file, an error will be thrown. This is most likely due to the testcafe file wrapper.
I expected testcafe to set the files and the application to upload the files. Using FormData is the most common way to upload files using an xhr without the need for the user to click on a submit button (using the change event).
Run the provided test case with skipJsErrors setted to false (this is the default value though)
Tested page URL: https://codepen.io/javiercbk/full/VyBgRr/
Test code
import path from 'path';
// make sure to point to an existing file
const TEST_FILE_PATH = path.join(__dirname, 'textfile.txt');
fixture`fileUpload`.page`https://codepen.io/javiercbk/full/VyBgRr/`;
test('fileupload', async (t) => {
await t.switchToIframe('#result').setFilesToUpload('input[type="file"]', TEST_FILE_PATH);
});
Hi @javiercbk,
Thanks for the report. I've reproduced the issue.
/cc @miherlosev @LavrovArtem Please take a look at this. I've reproduced this with the playground
Found a workaround https://codepen.io/javiercbk/full/NXLGGV/
The original case:
const f = files.item(i);
The modification:
let f;
try {
f = files.item(i);
} catch (err) {
if (err.message === 'Illegal invocation') {
f = files[i];
} else {
throw err;
}
}
Hi @javiercbk.
I've reproduced the problem and created the separate issue in another repository - https://github.com/DevExpress/testcafe-hammerhead/issues/1446.
When the issue is fixed, we will release a new version of TestCafe immediately.
@miherlosev I'm having the same issue with uploads. Can you update the version of testcafe-hammerhead on this project? Are you planning to do an npm publish any time soon?
Hi @cortezcristian .
[email protected] contains the fix of this problem. Try to install this version and tell us about the results.
@miherlosev thank you!
This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.