angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

ECONNREFUSED when using forkNewDriverInstance() without calling quit() #2203

Open barbogast opened 9 years ago

barbogast commented 9 years ago

Calling browser.forkNewDriverInstance() without calling quit() on the new instance afterwards throws an ECONNREFUSED error when protractor exits.

Example:


describe('forkNewDriverInstance() without calling quit()', function() {
    it('should not crash', function(){
        var newBrowser = browser.forkNewDriverInstance(false, true);
        //newBrowser.quit();    // if this is enabled the error disapears
    });
});

The error:

Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.0.44:45112/wd/hub
.

Finished in 0.91 seconds
1 test, 0 assertions, 0 failures

Shutting down selenium standalone server.

/home/ben/code/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:145
      callback(new Error(message));
               ^
Error: ECONNREFUSED connect ECONNREFUSED
    at ClientRequest.<anonymous> (/home/ben/code/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:145:16)
    at ClientRequest.emit (events.js:107:17)
    at Socket.socketErrorListener (_http_client.js:271:9)
    at Socket.emit (events.js:107:17)
    at net.js:459:14
    at process._tickCallback (node.js:355:11)
From: Task: WebDriver.quit()
    at [object Object].webdriver.WebDriver.schedule (/home/ben/code/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:360:15)
    at [object Object].webdriver.WebDriver.quit (/home/ben/code/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:443:21)
    at /home/ben/code/node_modules/protractor/lib/driverProviders/driverProvider.js:59:14
    at [object Object].promise.ControlFlow.runInFrame_ (/home/ben/code/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20)
    at [object Object].promise.Callback_.goog.defineClass.notify (/home/ben/code/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:2464:25)
    at [object Object].promise.Promise.notify_ (/home/ben/code/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12)
    at Array.forEach (native)
    at Object.goog.array.forEach (/home/ben/code/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/array/array.js:203:43)
    at [object Object].promise.Promise.notifyAll_ (/home/ben/code/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:552:16)
    at goog.async.run.processWorkQueue (/home/ben/code/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/async/run.js:125:21)
[launcher] Process exited with error code 1
[17:36:01] 'test:e2e' errored after 2.86 s
[17:36:01] Error: 1
    at formatError (/usr/lib/node_modules/gulp-cli/index.js:197:10)
    at Gulp.<anonymous> (/usr/lib/node_modules/gulp-cli/index.js:223:15)
    at Gulp.emit (events.js:107:17)
    at Gulp.Orchestrator._emitTaskDone (/home/ben/code/node_modules/gulp/node_modules/orchestrator/index.js:264:8)
    at /home/ben/code/node_modules/gulp/node_modules/orchestrator/index.js:275:23
    at finish (/home/ben/code/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
    at ChildProcess.cb (/home/ben/code/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3)
    at ChildProcess.g (events.js:199:16)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)

Calling quit() is not required, right? At least it says so here: https://github.com/angular/protractor/blob/9891d430aff477c5feb80ae01b48356866820132/spec/interaction/interaction_spec.js#L9

eolognt commented 9 years ago

I asked the same question on Stackoverflow and got the answer that you shouldn't expect the forks to be quitted automatically.

barbogast commented 9 years ago

Oh, all right, I didn't see your question. But based on the comment linked above and the commit implementing multiple browser it looks like the forks should quit automatically.

For example here: https://github.com/angular/protractor/commit/0bbfd2b6d38392938781d846ad37b5a0fd964004#diff-f379c4bb1bd89197b17ba4cd53cd8958R23

If it is indeed required to call quit() explicitly maybe it should be mentioned here: https://github.com/angular/protractor/blob/master/docs/browser-setup.md#using-multiple-browsers-in-the-same-test

eolognt commented 9 years ago

@Koblaid I think they should be quitted automatically, so this issue is relevant so the developer perhaps fix this.

sjelin commented 9 years ago

I agree that we should find a way to have the forked browsers quit cleanly/automatically