Seeker
Seeker

Reputation: 21

close() is not working, everytime a new window gets open

I am trying run the below mentioned code, its not working , everytime a new window gets open instead of closing the current window and opening a window.

public class Next2beforendafter {

    public static WebDriver driver;

    @BeforeMethod
    public void launchBrowser() {
        System.setProperty("webdriver.gecko.driver", "C:/Users/xyz/Videos/selenium/geckodriver-v0.11.1-win64/geckodriver.exe");
        driver = new FirefoxDriver();
    }

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

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

    @Test(priority = 3)
    public void verifybankofindiaTitle() {
        driver.get("http://www.bankofindia.co.in/english/home.aspx");
        Assert.assertEquals("Bank Of India - Home", driver.getTitle());
    }

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

Selenium Ver.3.0.1

Upvotes: 1

Views: 60

Answers (1)

Lucas Tierney
Lucas Tierney

Reputation: 2573

You should be using driver.quit() if you want to close the webdriver. driver.close() only closes the current window (tab) but leaves the driver session open

Upvotes: 1

Related Questions