Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
177 views
by Contributing Tester (92 points)

I am expecting here that after every method @AfterMethod annotation should be executed. However it doesnt seems working.


public class Q1 {

        public static WebDriver driver;

        @BeforeMethod
        public void launchBrowser() {
            System.setProperty("webdriver.gecko.driver", "C://geckodriver.exe");
            driver = new FirefoxDriver();
        }

        @Test(priority = 1)
        public void checkTitle() {
            driver.get("http://www.google.com");
            Assert.assertEquals("Google", driver.getTitle());
        }

        @Test(priority = 2)
        public void verifyTitle() {
            driver.get("https://in.yahoo.com");
            Assert.assertEquals("Yahoo", driver.getTitle());
        }

        @Test(priority = 3)
        public void validateTitle() {
            driver.get("http://www.google.ca");
            Assert.assertEquals("Google", driver.getTitle());
        }

        @AfterMethod
        public void closeBrowser() {
            driver.close();
        }
}

Help would be appreciated.

by The go-to Tester (181 points)
Try using driver.quit.

Also, post any exception you are facing.

Please log in or register to answer this question.

...