protractor: Add closeBrowserOnExit option

As discussed previously in #1425, now that Protractor is able to always close all browser instances when ending its process, it would be good to have the option to avoid this for debugging purposes.

i.e. Imagine having a closeBrowserOnExit setting that, when it is false, will let Protractor leave any remaining browser instance open after finishing its test run. That setting default value would be true though.

It would be useful because I think that the developer sometimes wants to access the browser “as-is” to inspect the page or logs and find out why a test framework (jasmine, cucumber, etc…) failed to close it automatically.

Just food for thought…

About this issue

  • Original URL
  • State: open
  • Created 10 years ago
  • Reactions: 5
  • Comments: 18 (8 by maintainers)

Most upvoted comments

There’s a thing that is driving us crazy. Our e2e tests fail randomly. You can’t use pause() in this case. Using debug allover the place is not a clean option.

There should be an option that stops protractor on failure, so you can debug the problem. Right now it’s not possible at all in our case and it’s really frustrating, causing our tests to have almost no value at all.

I have the same situation as topic starter. I used to develop on java + selenium webdriver and had to call driver.quit() in @after method. So when I needed to interact with browser I just commented out that line. I started to work in team that uses protractor for their tests and I’m in situation when I need to find faulty locator in some page that is hard to get to manually (you have to go through a long process of data inputs etc). I’m new to protractor and quite surprised that it doesn’t have “closeBrowserOnExit” suggested above

I want to throw my two cents in here.

I was writing a test, and suddenly chrome just closed while I was running it and protractor spat this out:

Failed: unknown error: cannot focus element
      (Session info: chrome=53.0.2785.143)
      (Driver info: chromedriver=2.25.426924 (649f9b868f6783ec9de71c123212b908bf3b232e),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 38 milliseconds
    Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
    System info: host: 'dune', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111'
    Driver info: org.openqa.selenium.chrome.ChromeDriver
    Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426924 (649f9b868f6783ec9de71c123212b908bf3b232e), userDataDir=/tmp/.org.chromium.Chromium.7sk4aP}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=53.0.2785.143, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
    Session ID: 096e49e783409d12aaf9f55929d697cf

This is not very useful, especially since if I have a long test and I’m not paying attention to chrome, I have no idea why it crashed because the error message gives no hint as to where it died and I can’t look in the browser because protractor closed it. I COULD go through every single line in the it() and add browser.pause() statements, but it’s incredibly frustrating seeing that it would be so much easier to fix if the browser didn’t close every time.

Protractor is supposed to make devs lives easier, but damn is it painful to write tests for.

You can… but when you have a a test with 10 assertions you then have to narrow down where the error happens and re-run the test… it would be nice to have the option for the test not to kill the driver so you can explore the test failure right after the assertion has failed and see what caused the failure…