Java Code Examples for com.gargoylesoftware.htmlunit.WebClient#closeAllWindows()

The following examples show how to use com.gargoylesoftware.htmlunit.WebClient#closeAllWindows() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuestionnairResourceInServletTest.java    From gazpachoquest with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void listTest() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
    final WebClient webClient = new WebClient();

    webClient.addRequestHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP
                                                                                        // 1.1.
    webClient.addRequestHeader("Pragma", "no-cache"); // HTTP 1.0.
    webClient.addRequestHeader("Expires", "0"); //
    final HtmlPage page = webClient.getPage(contextPath.toExternalForm() + "/testServlet");

    final String pageAsText = page.asText();

    System.out.println(pageAsText);

    webClient.closeAllWindows();

}
 
Example 2
Source File: DeployInWebAppsDirectoryTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
private void runTests(final String appUrl) throws IOException {
    final WebClient webClient = new WebClient();

    HtmlPage page = attempt(new Callable<HtmlPage>() {

        @Override
        public HtmlPage call() throws Exception {
            return getPage(webClient, appUrl);
        }
    }, 30);

    assertMoviesPresent(page);

    page = webClient.getPage(appUrl + "/moviefun");

    assertMoviesPresent(page);
    webClient.closeAllWindows();
}
 
Example 3
Source File: MoviesHtmlUnitTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Test
public void testShouldMakeSureWebappIsWorking() throws Exception {
    WebClient webClient = new WebClient();
    HtmlPage page = webClient.getPage("http://localhost:9999/moviefun/setup");

    assertMoviesPresent(page);

    try {
        page = webClient.getPage("http://localhost:9999/moviefun/faces/movie/List.xhtml");
    } catch (Exception e) {
        e.printStackTrace(); // just to get it in the console in debug phase
        throw e;
    }

    assertMoviesPresent(page);
    webClient.closeAllWindows();
}
 
Example 4
Source File: QuestionnairesUITest.java    From gazpachoquest with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void initTest() throws IOException, SAXException {
    System.out.println("hola holitas" + contextPath);
    final WebClient webClient = new WebClient();
    webClient.addRequestHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP
                                                                                        // 1.1.
    webClient.addRequestHeader("Pragma", "no-cache"); // HTTP 1.0.
    webClient.addRequestHeader("Expires", "0"); //
    final HtmlPage page = webClient.getPage(contextPath.toExternalForm() + "?invitation=12345678");

    final String pageAsText = page.asText();
    webClient.closeAllWindows();
}
 
Example 5
Source File: MoviesHtmlUnitTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Test
public void testShouldMakeSureWebappIsWorking() throws Exception {
    WebClient webClient = new WebClient();
    HtmlPage page = webClient.getPage("http://localhost:" + port + "/moviefun/setup.jsp");

    assertMoviesPresent(page);

    page = webClient.getPage("http://localhost:" + port + "/moviefun/moviefun");

    assertMoviesPresent(page);
    webClient.closeAllWindows();
}
 
Example 6
Source File: MoviesArquillianHtmlUnitTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Test
public void testShouldMakeSureWebappIsWorking() throws Exception {
    WebClient webClient = new WebClient();
    HtmlPage page = webClient.getPage(deploymentUrl + "/setup.jsp");

    assertMoviesPresent(page);

    page = webClient.getPage(deploymentUrl + "/moviefun");

    assertMoviesPresent(page);
    webClient.closeAllWindows();
}
 
Example 7
Source File: MoviesArquillianHtmlUnitTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Test
public void testShouldMakeSureWebappIsWorking() throws Exception {
    final String url = "http://" + deploymentUrl.getHost() + ":" + deploymentUrl.getPort() + "/moviefun";

    WebClient webClient = new WebClient();
    HtmlPage page = webClient.getPage(url + "/setup.jsp");

    assertMoviesPresent(page);

    page = webClient.getPage(url + "/moviefun");

    assertMoviesPresent(page);
    webClient.closeAllWindows();
}