protractor: setFileDectector unable to set remote file detector

I upgrade to 2.0.0 to test browser.setFileDetector() It is working locally with browser.setFileDectector(browser.FileDectector); However, it is not working with remote selenium server. I try browser.setFileDectector(browser.remote.FileDectector); It seems that selenium-webdriver/remote is not exposed from protractor. According to upload_test.js, https://github.com/SeleniumHQ/selenium/blob/baa16a551fb8d57f4a176b2f49c7af633dba2893/javascript/node/selenium-webdriver/test/upload_test.js We should do something like driver.setFileDetector(new remote.FileDetector); so I tried

    var absolutePath = path.resolve(__dirname, filePath);
    var remote = require('../../../../node_modules/protractor/node_modules/selenium-webdriver/remote');
    browser.setFileDetector(new remote.FileDetector);
    $('input[type="file"]').sendKeys(absolutePath);

But I got UnknownError: invalid code lengths set

  From: Task: WebElement.sendKeys()

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 23 (6 by maintainers)

Most upvoted comments

var remote = require(‘protractor/node_modules/selenium-webdriver/remote’); browser.setFileDetector(new remote.FileDetector());

The above script works for me when testing with browserstack. I’m using protractor 2.5.1

I ran into this problem as well and was completely stumped until I found this article: http://www.paulmcilwaine.com/development/protractor-saucelabs-and-file-upload. The author mentions that there is a bug where files larger than 80KB can’t be uploaded. When I switched to using an 8 KB file I was able to upload with no problem.