I want to test file uploading with this code, which was found here :
var path = require('path');
var fileToUpload = '..\\..\\files\\avatarPicture.jpg';
var absolutePath = path.resolve(__dirname, fileToUpload);
var fileElem = element(by.css('input[type="file"]'));
browser.executeScript(
"arguments[0].style.visibility = 'visible'; arguments[0].style.height = '1px'; arguments[0].style.width = '1px'; arguments[0].style.opacity = 1", fileElem.getWebElement());
browser.executeAsyncScript(function(callback) {
document.querySelector('input[type="file"]').style.display = 'inline';
callback();
});
$('input[type="file"]').clear().sendKeys(absolutePath);
and there is a WebDriverError:
Failed: File not found: C:\works\project\files\avatarPicture.jpg
- I already checked the path - it is correct. I can easily open file from command line
- I try to use both backslashes and slashes. There is still same error.
- WebDriver version: gecko v0.17.0
- Windows 10 Pro
- Everything is working on Chrome, but I need a solution for Firefox.