I'm testing an AngularJS project using protractor. I have an image file upload tests which is working and passing correctly on my local mac machine. However, when I run the same test via saucelabs the test fails.
Saucelabs is having problems finding the file and just opens a dialog box but can't find the file. The file is within my test solution and not in saucelabs. I've looked around on the web for answers but I haven't seen a definitive answer to resolve this particular problem. Below is an example of the code I am using to upload an image file against an application.
var path = require('path');
it('should upload a file', function() {
var fileToUpload = '../some/path/foo.txt',
absolutePath = path.resolve(__dirname, fileToUpload);
$('input[type="file"]').sendKeys(absolutePath);
$('#uploadButton').click();
});
Any help or suggestions on how to get the above code to work via Saucelabs will be much appreciated.
Have you tried something like:
browser.driver.setFileDetector(new browser.driver.remote.FileDetector);
According to the protractor issue it's either that or it's not working (bug in Selenium JavaScript bindings or protractor, or version mismatch).
In the same github issue there's also a workaround if the main solution didn't work (tldr: file sharing).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With