Reputation: 11
I have problem when trying to upload a csv of excel files via protractor. File is valid. When I upload it manually everything is fine. But for some reason, upload with protractor says that size is 0, and type is not recognized.
Screenshot of file details after upload
Upload code:
var fileToUpload = './test.csv';
var absolutePath = path.resolve(__dirname, fileToUpload);
element(by.css("input[type=\"file\"]")).sendKeys(absolutePath);
Also I have tried with absolute path, without path.resolve, and also I have tried with xlsx file. Problem remains the same.
Upvotes: 1
Views: 451
Reputation: 137
I believe I've found the cause. From my tests it seems like the File type
is missing, see below:
For a .csv
file:
File
lastModified: 1468589472000
lastModifiedDate: Fri Jul 15 2016 14:31:12 GMT+0100 (BST)
name: "valid-import.csv"
size: 198
type: ""
webkitRelativePath: ""
For a .svg
file:
File
lastModified: 1468587182000
lastModifiedDate: Fri Jul 15 2016 13:53:02 GMT+0100 (BST)
name: "valid-import.svg"
size: 1030
type: "image/svg+xml"
webkitRelativePath: ""
Note the missing type attribute — I'm trying to dig further into this, if I find anything I'll update this answer.
Upvotes: 0