swissmanu / protractor-screenshot-reporter

Reporter for Protractor. Asks Selenium for a screenshot after every test case and stores it along with test case details.
https://github.com/swissmanu/protractor-screenshot-reporter
MIT License
65 stars 21 forks source link

Tests untruly failing if screenshot taking is still in progress during test shutdown (ECONNREFUSED) #13

Open bentolor opened 10 years ago

bentolor commented 10 years ago

I get sporadically the following errors on using protractor-screenshot-reporter:

node_modules/protractor/node_modules/selenium-webdriver/http/index.js:136
      callback(new Error(message));
               ^
Error: ECONNREFUSED connect ECONNREFUSED
    at ClientRequest.<anonymous> (node_modules/protractor/node_modules/selenium-webdriver/http/index.js:136:16)
    at ClientRequest.emit (events.js:95:17)
    at Socket.socketErrorListener (http.js:1547:9)
    at Socket.emit (events.js:95:17)
    at net.js:440:14
    at process._tickCallback (node.js:419:13)
==== async task ====
WebDriver.takeScreenshot()
    at webdriver.WebDriver.schedule (node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:268:15)
    at webdriver.WebDriver.takeScreenshot (node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:871:15)
    at to.(anonymous function) [as takeScreenshot] (node_modules/protractor/lib/protractor.js:56:25)
    at ScreenshotReporter.reportSpecResults (node_modules/protractor-screenshot-reporter/index.js:123:10)
    at jasmine.NestedResults.totalCount [as reportSpecResults] (node_modules/protractor/node_modules/minijasminenode/lib/jasmine-1.3.1.js:1901:39)
    at jasmine.Spec.finishCallback (node_modules/protractor/node_modules/minijasminenode/lib/jasmine-1.3.1.js:2470:21)
    at jasmine.Spec.finish (node_modules/protractor/node_modules/minijasminenode/lib/jasmine-1.3.1.js:2475:8)
    at null.onComplete (node_modules/protractor/node_modules/minijasminenode/lib/jasmine-1.3.1.js:2504:10)
    at jasmine.Queue.next_ (node_modules/protractor/node_modules/minijasminenode/lib/jasmine-1.3.1.js:2219:14)

Fatal error: protractor exited with code: 1

Obviously the issue is that the Jasmine/Protractor-Tests already are shutting down and therefore the PhantomJS process terminates while the screenshot taking is still in progress.

In my opinition screenshot reporter should fail silently & gracefully instead of pulling the test itself into damnation here.

swissmanu commented 10 years ago

i'm not sure if this could really be fixed by the protractor-screenshot-reporter. the reporter only calls the webdriver api which completly handles the selenium browser lifecycle.

maybe you can supply more details otherwise?

bentolor commented 10 years ago

I read the stacktrace in that way, that Jasmine fails because it receives an Exception on calling ScreenshotReporter.reportSpecResults() via jasmine.Spec.finishCallback.

Pretty sure protractor-screenshot-reporter cannot avoid the failure during taking the screenshot. But I guess it can easily avoid the test failure of Jasmine by simple swallowing Exceptions received byScreenshotReporter.reportSpecResults() on calling the Webdriver API?

zoejobson commented 7 years ago

This is hitting our continuous integration - can anyone suggest a workaround ?