-
-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Upload with HTML file input does not work in Chrome 73 #34
Comments
The issue is fixed, but I'll keep this issue open for a while in order to receive some feedback if it's still persist for some other browsers. |
Not working if |
hey guys, thanks for all your help! idk why mine's not working on Chrome 73, it used to work :(
i have my Tried to follow the code not sure where to put |
Hey - would also really like the option to force this change because our inputs are often not visible (e.g. when using a label element to handle the clicks etc.) |
@ChrisSargent @rchovatiya88 |
Just released v3.0.5! |
@allcontributors[bot] add @ChrisSargent for question |
I've put up a pull request to add @ChrisSargent! 🎉 |
@allcontributors[bot] add @rchovatiya88 for question |
I've put up a pull request to add @rchovatiya88! 🎉 |
Awesome, thanks for the quick update! |
Thanks for the quick update and adding me as a contributor! @abramenal @ChrisSargent
it('Upload docs', () => {
cy.upload_file('license.jpg', 'image/jpg', '.front-image > .image-upload > input');
});
Cypress.Commands.add('upload_file', (fileName, type, selector) => {
cy.get(selector).then((subject) => {
cy.fixture(fileName, 'base64').then((content) => {
const el = subject[0];
const blob = b64toBlob(content, type);
cy.window().then((win) => {
const testFile = new win.File([blob], fileName, { type });
const dataTransfer = new DataTransfer();
dataTransfer.items.add(testFile);
el.files = dataTransfer.files;
});
});
});
cy.get(selector).trigger('change', { force: true });
});
function b64toBlob(b64Data, contentType = '', sliceSize = 512) {
const byteCharacters = atob(b64Data);
const byteArrays = [];
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
const slice = byteCharacters.slice(offset, offset + sliceSize);
const byteNumbers = new Array(slice.length);
for (let i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
const blob = new Blob(byteArrays, { type: contentType });
blob.lastModifiedDate = new Date();
return blob;
} |
As a first step I would suggest providing If that works for you, likely this is a bug connected to our environment auto-detection. If so, please bring more details on your setup (node / browser / os versions, dockerfile, etc., anything that may be useful for investigation). If that still doesn't work for you – then it is either a problem with the package usage in your code, or weird fixture that you're trying to upload. Looking forward your reply! |
Hi, I'm using
|
And for me not working. using Chrome 80.
test.js
|
Probably this recipe got a bit wasted, so here it is again:
There's an auto-detection mechanism for checking chrome version (and if it is greater or equal to 73 there's a forced even trigger).
Learn more about the setup used: |
Thanks for the answer, I am sent the new issue with details |
Current behavior:
File upload does not gets triggered when using Chrome v73 and higher.
There were no info in Chrome changelog:
https://developers.google.com/web/updates/2019/03/nic73
UPD:
Found related Chromium bug which seems to be fixed in corresponding Chrome release:
https://bugs.chromium.org/p/chromium/issues/detail?id=792336
Code snippets:
Electron 59:
el.files = [testFile]
trigger change on inputChrome >69:
el.files = [testFile]
trigger change on inputChrome 73:
el.files = [testFile]
not trigger change on inputThis issue is fixed in #29.
Linked issue: cypress-io/cypress#3730
Desired behavior:
File upload should work seamlessly on any platform.
Versions
Chrome: >73
The text was updated successfully, but these errors were encountered: