Closed RajS999 closed 3 years ago
When I upload the png file (when the expected input file is something else, in my case *.py file), website gives error
ERROR: You have submitted a file factorial.py of type py but the contents are of application/octet-stream type.
I get same error with jpg and mp3 file upload.
Website should give error:
ERROR: You have submitted a file factorial.py of type py but the contents are of image/png type
as this is the error I get when I manually upload (not through cypress) png file.
I tried following:
cy.get('input[name="docfile"]').attachFile(filePath) cy.contains('input','Upload').click()
Specifying mimetype explicitly still gives me same error:
cy.get('input[name="docfile"]').attachFile({ filePath: _filePath, mimeType : _mimeType })
I am on Windows 10. Following are nore related versions:
>node --version v14.16.0 > npm --version Debugger attached. 6.14.11
package.json
{ "name": "myproj-testing", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "merge":"mochawesome-merge cypress/reports/*.json>cypress/reports/merged_report.json", "generate_mochawesome_report": "marge cypress/reports/merged_report.json --reportDir ./ --inline", "final_report": "npm run merge && npm run generate_mochawesome_report", "generate_report": "python cypress/utils/merge.py && npm run generate_mochawesome_report" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "cypress": "^8.3.0", "cypress-file-upload": "^5.0.8" }, "devDependencies": { "mocha": "^9.1.1", "mochawesome": "^6.2.2", "mochawesome-merge": "^4.2.0" } }
Hi @RajS999 You should set encoding property to tell how exactly the file should be processed.
encoding
Current behavior:
When I upload the png file (when the expected input file is something else, in my case *.py file), website gives error
I get same error with jpg and mp3 file upload.
Desired behavior:
Website should give error:
as this is the error I get when I manually upload (not through cypress) png file.
Steps to reproduce: (app code and test code)
I tried following:
Specifying mimetype explicitly still gives me same error:
Versions
I am on Windows 10. Following are nore related versions:
package.json