unadulterated faff

Controlling a Selenium WebDriver through a Python ContextManager

Over time, I’ve found myself less and less willing to close things manually in Python: ever since I found out about context managers and the with statement, I find myself writing context managers to handle any managed resource I need to deal with.

Want to open a file? Do it in a context manager. Want to connect to a database? Do it in a context manager. Want to pause garbage collection? Do it in a context manager.