Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Say I have this function:

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

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

self.driver.save_screenshot('path')

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 (http://nose.readthedocs.org/en/latest/).

share|improve this question

2 Answers 2

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
        self.driver.quit()
share|improve this answer

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

Your Answer

 
discard

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.