Reputation: 55
I have 2 methods to be run in TestNg framework but my code executes only @Test and @AfterMethod does not execute.
Please find output of result. As you can see, only AdminLogin method run and Closebrowser method failed and did not provide any result due to that it skipped other 2 test.
Upvotes: 0
Views: 2640
Reputation: 2674
Possible solution:
Instead of trying to create a new Object, just initialize it everytime ion all the methods. So, instead of doing
WebDriver driver = new ChromeDriver();
Try using
driver = new ChromeDriver();
Also, for the @AfterMethod you can use annotation:
@AfterMethod(alwaysRun = true)
Upvotes: 1