I am trying to upload a file to web form on e2e test with protractor. The file is not uploaded and the input field stay empty.
this is the code:
it('should uploaded', ()=>{
const fileToUpload = '../src/files/somefile.csv';
const path = require('path');
const remote = require('selenium-webdriver/remote');
browser.setFileDetector(new remote.FileDetector());
const absolutePath = path.resolve(__dirname, fileToUpload);
const fileElem = await element.all(by.css('input[type="file"]')).get(0);
fileElem.sendKeys(absolutePath);
// except input file to be not empty
});
The path is correct and the file is exist on this path. no error occurs. I just see on the browser the input field empty. whats wrong? why it not uploaded?