I close my driver and reopen it between each negative test, for example - in my negative login test - if the test failed it means the login succeeded, then I close the driver and open it again so I start from a fresh browser in the login page again.
Is it best practice to do it that way? I thought about some alternatives but I can't decide which one is better -
- closing the driver only when I actually need to - for example when the test failed and it logged in.
- clear the browser cache and cookies between each test, so it'll simulate new driver.