javascript error when running selenium test suite

A strange problem occurred when I was running one of my selenium test suites. The test would run fine for my first testcase (that is, the first “method”). If you know a little about how selenium works, you’ll know that the teardown method is called after each method.
The teardown basically grabs any errors that occurs and kills the browser session, thus opening a new session in your next method. The issue that was occurring was this annoying JavaScript error being pulled from Internet Explorer, saying it cannot run scripts on the page. It halted my script and I had no way to get to the following methods…so after a little digging around I found a solution…
All you need to do, is replace your current teardown method with this