Afamee
Afamee

Reputation: 5320

Selenium fails to kill browser when test fails

How do I set up Selenium to kill the test browser page on occasions where the test fails?

Currently, when running Selenium test cases and a test fails, the browser page stays open and that causes problems when a large number of tests is failing. Interestingly enough, it isn't the case when the test passes.

Any suggestion??

Upvotes: 1

Views: 2034

Answers (2)

Lynden Shields
Lynden Shields

Reputation: 1062

Its not quite that simple, in my experience anyway (I'm new to selenium and JUnit). It depends how the failure occurs and what you do with it. JUnit should automatically call tearDown() when a test fails, and selenium.stop() should be in this. However sometimes tearDown() isn't called, for instance when the error occurs in setUp(), or if you're doing something sill when a failure occurs.

Upvotes: 0

Patrick Lightbody
Patrick Lightbody

Reputation: 4534

You should call selenium.stop() of course :) It sounds like you need a try/finally block

Upvotes: 2

Related Questions