Protractor file uploads - Support remote uploads with webdriver setFileDetector & LocalFileDetector
See original GitHub issueRight now it is perfectly possible to upload files for an input file element like this (Andres example)
var util = require('util');
it('should upload file', function() {
var fileToUpload = '../some/path/foo.txt',
var absolutePath = path.resolve(__dirname, fileToUpload);
$('input[type="file"]').sendKeys(absolutePath);
$('#uploadButton').click();
});
I’ve tested this on an ajax multi-file uploader and works! is awesome.
The issue is how to use this on a remote selenium grid like BrowserStack or Sauce Labs.
Since selenium 2.8.0 they have
Added setFileDetector to RemoteWebDriver to allow files to be uploaded to the remote server
But only java bindings seems to be available so i wonder if this is going to be possible on protractor.
The workaround i tried to use was uploading the target file to a publicly accessible server and then on the sendKeys()
put the complete URI, e.g. http://my-server.com/fileToUpload.doc
but that only works on Windows machines, linux complains with UnknownError: unknown error: path is not absolute: http://....
and OSX failed too.
Issue Analytics
- State:
- Created 10 years ago
- Comments:26 (7 by maintainers)
Top GitHub Comments
It’s resolved using setFileDetector 😃
Hi all, @juliemr
I am end up with a strage issue. I can upload the file using the sendkeys() method in chrome. But not on firefox or remote chrome driver. It says invalid file path though the path is valid. Should I use setFileDetector to resolve it? Please comment