1

I'm receiving the following error in a protractor test when trying to upload a CSV file.

  - Failed: "port" option should be >= 0 and < 65536: 100000

I inherited these tests but there is no reference of port settings in any of the tests or the config files. Below is where the code is failing. Similar code is used in other tests to upload an image and works successfully.

var path = require('path');
var localPath = process.cwd();
var csv = localPath + '/test_app/resources/new_contact.csv';
var absolutePath = path.resolve(__dirname, csv);

  guestList.uploadBtn.click();            
  browser.executeScript('$(\'input[type="file"]\').attr("style", "");');
  browser.wait(EC.presenceOf($('input[type="file"]')), 10000);
  // Send filepath to file input
  $('input[type="file"]').sendKeys(absolutePath);      

What do I need to change and where so the CSV will upload successfully?

Edit:

describe('Upload a new contact using the "Bulk Upload Contacts" feature', function () {
    var csvContent = {
        guest1: {
            firstName: 'Derp',
            lastName: 'Derpington',
            email: 'derpderpington@google.com',
            company: 'The Derps, LLC.'
        },
    };

    it('should open the "Add Contact" modal', function () {
        guestList.bulkContactUploadBtn.click();
        browser.wait(EC.presenceOf(guestList.modal), 10000);
        expect(guestList.modal.isPresent()).toEqual(true);
        expect(guestList.submitUpload.getAttribute('disabled')).toEqual('true');
    });

    it('should upload a guest csv', function () {
        var path = require('path');
        var localPath = process.cwd();
        var csv = localPath + '/test_app/resources/new_contact.csv';
        var absolutePath = path.resolve(__dirname, csv);

        guestList.uploadBtn.click();

      browser.executeScript('$(\'input[type="file"]\').attr("style", "");');
        browser.wait(EC.presenceOf($('input[type="file"]')), 10000);
      // Send filepath to file input
        $('input[type="file"]').sendKeys(absolutePath);
        browser.pause(100000);
        browser.wait(EC.presenceOf(guestList.progressBar), 10000); 
        guestList.addContactOverride.click();
        guestList.submitUpload.click();
  • The error looks unrelated to the code you've posted. What do you have in your Protractor config? – alecxe Jul 19 '17 at 17:36
  • exports.config = { directConnect: true, seleniumAddress: 'http://127.0.0.1:4444/wd/hub', framework: 'jasmine2', capabilities: { 'browserName': 'chrome' }, params: require('./testdata.json'), and then just code to run reports. – kylokyler Jul 19 '17 at 17:39
  • Okay, could you post the complete test spec that you execute, the stacktrace of the error and specify how do you start your tests? Thanks! – alecxe Jul 19 '17 at 19:02
  • Full test added. Essentially, a button is clicked to 'bulk upload', then the file needs to be selected. I'm running my test through the terminal protractor automation_conf.js --original – kylokyler Jul 19 '17 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.