teerapap / grunt-protractor-runner

A Grunt plugin for running protractor runner.
MIT License
149 stars 123 forks source link

Error: ECONNREFUSED connect ECONNREFUSED #99

Closed Mike-Hardy closed 9 years ago

Mike-Hardy commented 9 years ago

when running Chrome in multicapabilities. Running on Windows 8.1 x64.

Gruntfile.js =


module.exports = function (grunt) {

    // Project configuration.
    grunt.initConfig({
        protractor_webdriver: {
            e2eUpdate: {
                options: {
                    path: './node_modules/.bin/',
                    command: 'webdriver-manager update --standalone'
                },  
            },  
            e2eStart: {
                options: {
                    path: './node_modules/.bin/',
                    command: 'webdriver-manager start'
                },  
            },              
        },
        protractor: {
            options: {
                configFile: "ProtractorConfig.js",
                keepAlive: true, // If false, the grunt process stops when the test fails.
                noColor: false, // If true, protractor will not use colors in its output.
                args: {

                    // Arguments passed to the command
                }
            },
            e2e: {
                // Grunt requires at least one target to run so you can simply put 'all: {}' here too.
                options: {
                    configFile: "ProtractorConfig.js", // Target-specific config file
                    args: {} // Target-specific arguments
                }
            },
        },
    });
    grunt.loadNpmTasks('grunt-protractor-webdriver');
    grunt.loadNpmTasks('grunt-protractor-runner');

    // Default task(s).
    grunt.registerTask('default', ['protractor_webdriver:e2eStart', 'protractor:e2e']);
};

package.json =


{
    "name": "UI.NodeE2ETests",
    "version": "1.0.0",
    "description": "UI.NodeE2ETests",
    "private": false,
    "author": "fifteenbelow",
    "devDependencies": {
        "grunt-protractor-runner": "~1.1.4",
        "grunt-protractor-webdriver": "~0.1.9",         
        "jasmine-reporters": "<2.0.0"       
    },
    "scripts": {
    "postinstall": "node_modules/.bin/webdriver-manager update --standalone"
  }
}

protractorConfig.js =


exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['../src/UI.NodeE2ETests/tests/**/*spec.js'],
    multiCapabilities: [,{
            browserName: 'chrome'
        }],
    jasmineNodeOpts: {
    onComplete: null,
    defaultTimeoutInterval: 180000,
    isVerbose: true,
    showColors: true,
    includeStackTrace: true
    },
    allScriptsTimeout: 180000,
    framework: 'jasmine',
    onPrepare: function() {
        if (process.env.TEAMCITY_VERSION)
        {
            require('jasmine-reporters');
            jasmine.getEnv().addReporter(new jasmine.TeamcityReporter());
        }
    }
}

Output from tests =


Running "protractor_webdriver:e2eStart" (protractor_webdriver) task
Starting Selenium server
Started Selenium server: http://127.0.0.1:4444

Running "protractor:e2e" (protractor) task
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Session created: count=1, browserName=chrome
Elements feature
  should be able to delete and add a element - pass

Send notification feature
  should be able to create and send a manual notification - pass
Signin invalid feature
  should not sign in with invalid credentials - pass
Signin feature
  should sign in using valid credentials - pass
Templates and Subjects feature
  should be able to delete and add a template and delete and add a subject - pas
s
Tenants feature
  should display tenants - pass
  should be able to select tenant - pass
  should be able to switch tenant - pass

Finished in 198.995 seconds
8 tests, 43 assertions, 0 failures

Session deleted: Going to shut down the Selenium server
Shutting down Selenium server: http://127.0.0.1:4444
Shut down Selenium server: http://127.0.0.1:4444 (OKOK)

D:\Git\XXX.AcceptanceTests\build\node_modules\grunt-protractor-runner\node_
modules\protractor\node_modules\selenium-webdriver\http\index.js:145
      callback(new Error(message));
               ^
Error: ECONNREFUSED connect ECONNREFUSED
    at ClientRequest.<anonymous> (D:\Git\XXX.AcceptanceTests\build\node_mod
ules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdr
iver\http\index.js:145:16)
    at ClientRequest.emit (events.js:95:17)
    at Socket.socketErrorListener (http.js:1551:9)
    at Socket.emit (events.js:95:17)
    at net.js:440:14
    at process._tickCallback (node.js:419:13)
==== async task ====
WebDriver.quit()
    at [object Object].webdriver.WebDriver.schedule (D:\Git\XXX.AcceptanceT
ests\build\node_modules\grunt-protractor-runner\node_modules\protractor\node_mod
ules\selenium-webdriver\lib\webdriver\webdriver.js:345:15)
    at [object Object].webdriver.WebDriver.quit (D:\Git\XXX.AcceptanceTests
\build\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules
\selenium-webdriver\lib\webdriver\webdriver.js:418:21)
    at D:\Git\XXX.AcceptanceTests\build\node_modules\grunt-protractor-runne
r\node_modules\protractor\lib\driverProviders\driverProvider.js:28:16
    at D:\Git\XXX.AcceptanceTests\build\node_modules\grunt-protractor-runne
r\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\base.js:1582:
15
    at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (D:\Git\XXX.AcceptanceTests\build\node_modules\grunt-protractor-runner\node_modules\pro
tractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1654:20)
    at notify (D:\Git\XXX.AcceptanceTests\build\node_modules\grunt-protract
or-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\
promise.js:465:12)
    at [object Object].then (D:\Git\XXX.AcceptanceTests\build\node_modules\
grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\
lib\webdriver\promise.js:522:7)
    at D:\Git\XXX.AcceptanceTests\build\node_modules\grunt-protractor-runne
r\node_modules\protractor\lib\driverProviders\driverProvider.js:26:25
    at Array.map (native)
[launcher] Process exited with error code 1
>>
>> Test failed but keep the grunt process alive.

Note we are running grunt from F# Fake, but this should have no bearing on this error.

If i change my protractorConfig to use


multiCapabilities: [,{
            browserName: 'firefox'
        }],

then i do not get the error.

MrDefinite commented 9 years ago

+1 same problem. Environment: "protractor": "^1.5.0", "grunt-protractor-runner": "^1.1.4", "jasmine-reporters": "^1.0.1", "grunt-protractor-webdriver": "^0.2.0"

Mike-Hardy commented 9 years ago

I've resolved this by specifying the binary in 'chromeOptions'


exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['../src/UI.NodeE2ETests/tests/**/*spec.js'],
    multiCapabilities: [{
            'browserName': 'chrome',
            'chromeOptions': {
                binary: 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe',
                args: [],
                extensions: [],
            }
        }, {
            'browserName': 'firefox'
        }],
    maxSessions: 1,
    jasmineNodeOpts: {
    defaultTimeoutInterval: 180000,
    isVerbose: true,
    showColors: true,
    includeStackTrace: true
    },
    allScriptsTimeout: 180000,
    framework: 'jasmine',
    onPrepare: function() {
        if (process.env.TEAMCITY_VERSION)
        {
            require('jasmine-reporters');
            jasmine.getEnv().addReporter(new jasmine.TeamcityReporter());
        }
    }
}
Mike-Hardy commented 9 years ago

@MrDefinite can you confirm that you are able to resolve this in the same way ? Note: i have chrome installed globally hence the location C:/Program Files (x86)/Google/Chrome/Application/chrome.exe

MrDefinite commented 9 years ago

@spikeybill No...I got same error using your way. In addition, if I set Selenium server keep alive, no error will be throw. However I think it maybe not good because I want my tests run on Jenkins.

Mike-Hardy commented 9 years ago

@MrDefinite well i think that specifying keepalive and the chrome binary location has solved this for me. The fact that you are not getting Error: ECONNREFUSED connect ECONNREFUSED probably means that the chrome exe has been located. Would you like to post another issue with all your package, protractor config, gruntfile. jenkins config ? I will close this issue as it is non jenkins related.

Mike-Hardy commented 9 years ago

@ mention me in the new issue so i can take a look

jrust commented 9 years ago

I'm also experiencing this issue. It only happens on Windows and the only solution I've found is to set keepAlive to true. The downside with that solution is that it leaves the selenium process running.

yoav-zibin commented 8 years ago

Same issue for me, on MAC (using latest version of protractor): 1 spec, 0 failures Finished in 8.133 seconds Shutting down selenium standalone server. Unhandled error: Error: ECONNREFUSED connect ECONNREFUSED 192.168.1.152:49520 Unhandled error: Error: ECONNREFUSED connect ECONNREFUSED 192.168.1.152:49520

I managed to solve it by setting: directConnect: true Sadly, this solution doesn't work for safari: Error: browserName (safari) is not supported with directConnect.

BTW, I confirmed I have the error because I use: browser.forkNewDriverInstance(); If I use only one browser, then the error also disappears. (But I have to use two browsers in my tests because it's for a multiplayer game :))

yoav-zibin commented 8 years ago

I managed to solve it (even for Safari) by running selenium standalone server using another grunt plugin: https://www.npmjs.com/package/grunt-selenium-standalone

Before the protractor trask I start the selenium server, and I stop it afterward: selenium_standalone:seleniumTask:start, ... selenium_standalone:seleniumTask:stop,

masterspambot commented 8 years ago

directConnect: true

Solves the problem for Chrome and FF.

faminram commented 8 years ago

I am using directConnect: true

but still getting the issue