Closed mingyixu closed 3 years ago
Hi @mingyixu
Thanks for submitting the issue!
The two code snippets you mention use different encodings.
I think the correct one is binary
which should automatically be recognized by the tool.
Here are things you can try:
cy.get('#pic').attachFile('abc.jpg', { subjectType: 'drag-n-drop' });
// OR
cy.get('#pic').attachFile({ filePath: 'abc.jpg', mimeType: 'image/jpg', encoding: 'binary' }, { subjectType: 'drag-n-drop' });
If you have tried this and still see the issue, feel free to reopen this so we can investigate it further. Thanks!
According to cypress implementation the default encoding for images is base64
. Hence, keeping it as default in this plugin as well.
If you need a different one, you can use encoding
property as I have described above
Current behavior:
I'm trying to upload an image to a file. This is my code cy.get('#pic').attachFile({ filePath: 'abc', mimeType: 'image/jpg', encoding: 'base64' }, { subjectType: 'drag-n-drop' });
on mac is success, but cann't upload on linux. its must use : cy.fixture("abc.jpg", 'binary') .then(Cypress.Blob.binaryStringToBlob) .then((fileContent) => { cy.get('#pic').attachFile({ fileContent, fileName: 'abc.jpg', mimeType: 'image/jpg', encoding: 'utf-8' }); }) this method not nice.
Desired behavior:
Steps to reproduce: (app code and test code)
Versions