views:

713

answers:

2

How do I setUp selenium to kill the test browser page on occasions where test fails. Currently, when running selenium test cases and a test fails, the browser page stays open and that causes problems when large number of tests is failing. Interestingly enough, it isnt the case when the test passes. Any suggestion??

+2  A: 

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

Patrick Lightbody
duh! thanks a bunch
Afamee
A: 

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.

Lynden Shields