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

0 like 0 dislike
176 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.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...