Selenium Prevent Browser From Closing For CLI Debug

Dec 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: ')driver.quit()

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.