Example usage for org.openqa.selenium WebDriver close

List of usage examples for org.openqa.selenium WebDriver close

Introduction

In this page you can find the example usage for org.openqa.selenium WebDriver close.

Prototype

void close();

Source Link

Document

Close the current window, quitting the browser if it's the last window currently open.

Usage

From source file:PageObjectModel.Browser.java

static void ClosePage() {
    WebDriver.close();
}

From source file:post.Util.java

License:Open Source License

public static String getUrlFromPostFbCode(String postfbcode) {
    String[] split = postfbcode.split("_");
    String page_id = split[0];/*w ww  .j ava  2  s .co  m*/
    String post_id = split[1];
    String href = "";
    String url = Globals.S1 + page_id + Globals.S2 + post_id;
    WebDriver driver = new FirefoxDriver();
    driver.get(url);
    try {
        WebElement element = driver.findElement(By.xpath("//a[contains(@class, '" + Globals.link + "')]"));
        href = element.getAttribute("href");
    } catch (Exception e) {
        System.out.println("WARNING: POST " + url + " -> Questo contenuto non  al momento disponibile");
        e.printStackTrace();
    }
    driver.close();
    return href;
}

From source file:pt.fccn.arquivo.pages.OpenSearchPage.java

License:Open Source License

/**
 * It is only needed when the test is run individually, if not IndexPage will set this variable
 * Verify that the term exists in as a search result
 * @param query Term that was searched/*from   ww  w  .  j a v  a2 s.  c o  m*/
 * @return true if the term exists in the first result title or in the snippet text
 */
public String setFirstResult(String searchTerms) {

    //Create a new firefox driver
    WebDriver searchDriver = new FirefoxDriver();
    searchDriver.get(driver.getCurrentUrl().split("opensearch")[0]);
    searchDriver.findElement(By.id(searchBox)).clear();
    searchDriver.findElement(By.id(searchBox)).sendKeys(searchTerms);
    searchDriver.findElement(By.id(searchButton)).submit();
    WebElement listOfResults = searchDriver.findElement(By.id(listOfResultsTag));
    searchDriver.close();
    return listOfResults.findElement(By.xpath("//*[@id=\"resultados-lista\"]/ul/li[1]/h2")).getText();
}

From source file:qsp.popups.ActiTimewinhand.java

public static void main(String[] args) throws Throwable {
    WebDriver driver = new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    driver.get("http://localhost/login.do");
    driver.findElement(By.id("licenseLink")).click();

    driver.findElement(By.xpath("//a[.='actiTIME Inc.']")).click();
    Set<String> allwh = driver.getWindowHandles();
    System.out.println(allwh.size());
    for (String aw : allwh) {
        driver.switchTo().window(aw);/*  w  ww .  j  a v a 2 s  . com*/
        System.out.println(driver.switchTo().window(aw));
        driver.close();
    }

}

From source file:renascere.Renascere.java

License:Open Source License

/**
 * @Description Method that closes a browser instance
 *///from w  w w . ja v a  2s.co  m
public static void closeBrowser(WebDriver driver) {
    //Closing browser
    try {
        driver.close();
        driver.quit();
    } catch (Exception e) {
        frmError("closing a browser instance.", e.getMessage(), severity.HIGH);
    }
}

From source file:se.claremont.SandBoxTest.java

@Ignore
@Test/*from w  w  w  .j  a  v a2s  .  c o m*/
public void phantomJSdriverTest() {
    WebDriverManager wdm = new WebDriverManager(currentTestCase);
    WebDriver driver = wdm.initializeWebDriver(WebDriverManager.WebBrowserType.PHANTOMJS);
    driver.get("http://www.claremont.se");
    currentTestCase.log(LogLevel.INFO, driver.getTitle());
    currentTestCase.log(LogLevel.INFO, currentTestCase.toJson());
    driver.close();
}

From source file:SmokeTests.Settings.BrowserSettings.java

@AfterTest
public void tearDown(WebDriver driver) {
    System.out.println("Close WebDriver");
    totalResultMessage += "Close WebDriver";
    driver.close();
}

From source file:uk.q3c.krail.testbench.KrailTestBenchTestCase.java

License:Apache License

@After
public void baseTearDown() {
    System.out.println("closing all drivers");
    for (WebDriver webDriver : drivers) {
        System.out.println("closing web driver: " + webDriver.getTitle() + "");
        webDriver.close();

    }/*from w  ww.  j  a  va 2 s  .  c o  m*/
    //        if (!drivers.contains(driver)) {
    //            driver.close();//in case it was set directly and not through addDriver
    //        }

    drivers.clear();
}

From source file:Utility.General.java

License:Open Source License

public void CloseConnection(WebDriver driver) {

    driver.close();
    Log.info("Connection closed.");

}

From source file:utils.WebDriverUtils.java

public static void closeCurrentWindow(WebDriver webDriver) {
    webDriver.close();
}