@ruimalheiro I like your idea for what you're doing here, but assertTrue(True/False) is weird.  If the code asserts, the test will fail--so really, you don't need to check anything.

I think to set this up as a try... finally (for the driver.cose) is the best way to do it, with a check for any JS errors as @jamalex suggested.