question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Protractor file uploads - Support remote uploads with webdriver setFileDetector & LocalFileDetector

See original GitHub issue

Right 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:closed
  • Created 10 years ago
  • Comments:26 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rakeshnambiarcommented, Nov 28, 2018

It’s resolved using setFileDetector 😃

0reactions
rakeshnambiarcommented, Nov 27, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Remote File Upload Protractor test
First of all, for the file upload to work with remote selenium servers ... remote uploads with webdriver setFileDetector & LocalFileDetector.
Read more >
protractor remote file upload
Uploading files in WebDriver is done by simply using the sendKeys() method on the file-select input field to enter the path to the...
Read more >
How can I work with file uploads during a Webdriver test?
Uploading files using Webdriver. Note: this answer applies to Selenium 2. ... setFileDetector(new LocalFileDetector()); WebElement upload = driver.
Read more >
Local File Detector to handle file uploads on remote ...
Hello, I'm running the scripts I've created through Katalon remotely through the CrossBrowserTesting (CBT) application, and the UploadFile ...
Read more >
Test file upload in Selenium test
Learn how to test the file upload functionality of your web app in Selenium using BrowserStack ... LocalFileDetector; import org.openqa.selenium.remote.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found