Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I have this function:

    def tearDown(self):
    """ clean up by closing the browser window """

I want to skip closing the browser if the test failed or errored out (so I can examine what was on the screen when the test last left off). Is this possible?

Let's say I don't even care if the browser closes, because I can do


I still need the "if test failed" logic to make that happen, so I won't have to dig through hundreds of screenshots to find the failed test.

I'm using nose as my test runner (

share|improve this question

As far as I can tell, your question is more about Nose than Selenium. You want errors and failures to do something that successes do not. I do not have any experience with Nose, but the documentation suggests that you could write your own ErrorClass plugin that will take a screenshot when the error/failure occurs.

share|improve this answer

I can't believe it was this simple, but this seems to work!

def tearDown(self):
    """ clean up by closing the browser window """
    if not Exception:  # leave failed test windows open
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.