Selenium Prevent Browser From Closing For CLI Debug

December 22, 2018

It seems like the browser opened by selenium will automatically closed when the calling application end, regeraless if driver.quit() is called or not.

If an exception happend, the browser shall remain opened.

NOTE: Tested on Selenium 3.141 with chrome driver. This behaviour might not be consistent.

I am building a CLI app, so I use an accept input command to stop the application from ending (prevent browser close).

input('Hit Enter to quit: ')

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.