0

after my test is finished browser is not closed. I understand that i need to declare driver.close() method. But which practise is best, where should i declare that?

i need that after every test is finished (failed or passed, nvm), browser should be closed.

my test for exmpl.

public void createOrganization() throws InterruptedException {
        new loginPage()
                .loginToSystemAsVPTSpecialist();
        new createOrganization()
                .clickButtonCreateJA()
                .selectMembership()
                .clickButtonFillUserData();
    }
Jetz
  • 207
  • 2
  • 4
  • 14
  • 3
    If you are using framworks like JUnit or TestNG, you can write a method that closes the driver and annotate it so it is called once after all test have finished. In Unit, it's [`@AfterAll`](https://junit.org/junit5/docs/5.0.2/api/org/junit/jupiter/api/AfterAll.html) – deHaar Nov 15 '21 at 16:29
  • Thank you for answer, but where i should put this method? – Jetz Nov 15 '21 at 16:38
  • 1
    You can put that method in classes that contain tests. Have a look at [this question](https://stackoverflow.com/questions/9903341/cleanup-after-all-junit-tests) (where the old annotation `@AfterClass` was used (JUnit 4)). There are alternatives as well. – deHaar Nov 15 '21 at 16:49

0 Answers0