Search in sources :

Example 81 with WebClient

use of com.gargoylesoftware.htmlunit.WebClient in project Payara by payara.

the class MicroprofileSecureEndpointTest method setup.

@Before
public void setup() throws FileNotFoundException, IOException {
    webClient = new WebClient();
    correctCreds.addCredentials("mp", "mp");
    incorrectCreds.addCredentials("random", "random");
    serverBase = ServerOperations.createClientTrustStore(webClient, base, clientKeyStorePath).toString();
}
Also used : WebClient(com.gargoylesoftware.htmlunit.WebClient) Before(org.junit.Before)

Example 82 with WebClient

use of com.gargoylesoftware.htmlunit.WebClient in project Payara by payara.

the class MicroProfileRestClientIT method testRetry.

@Test
public void testRetry() throws Exception {
    Page page = new WebClient().getPage(baseUrl + "/resources/javaee8");
    Assert.assertEquals(HttpServletResponse.SC_OK, page.getWebResponse().getStatusCode());
}
Also used : Page(com.gargoylesoftware.htmlunit.Page) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test)

Example 83 with WebClient

use of com.gargoylesoftware.htmlunit.WebClient in project Payara by payara.

the class SecureCustomHttpListenerTest method setUp.

@BeforeClass
public static void setUp() {
    WEB_CLIENT = new WebClient();
    WEB_CLIENT.getOptions().setThrowExceptionOnFailingStatusCode(false);
    WEB_CLIENT.getOptions().setUseInsecureSSL(true);
}
Also used : WebClient(com.gargoylesoftware.htmlunit.WebClient) BeforeClass(org.junit.BeforeClass)

Example 84 with WebClient

use of com.gargoylesoftware.htmlunit.WebClient in project Payara by payara.

the class OAuthTest method init.

@Before
public void init() {
    webClient = new WebClient();
    System.out.println("Set up new WebClient");
}
Also used : WebClient(com.gargoylesoftware.htmlunit.WebClient) Before(org.junit.Before)

Example 85 with WebClient

use of com.gargoylesoftware.htmlunit.WebClient in project chuidiang-ejemplos by chuidiang.

the class JavascriptWithHtmlUnit method main.

public static void main(String[] args) throws Exception {
    WebClient webClient = new WebClient();
    HtmlPage page = webClient.getPage("file:files/JavascriptWithHtmlUnit.html");
    // Sale "hola", puesto que se ha ejecutado el codigo javascript de la pagina
    System.out.println(page.getElementById("unDiv").getTextContent());
    // Cambiamos el contenido usando funciones est�ndar de javascript en navegador
    page.executeJavaScript("document.getElementById(\"unDiv\").innerHTML=\"que tal?\"");
    System.out.println(page.getElementById("unDiv").getTextContent());
    // Cambiamos el contenido con una funcion javascript definida en la pagina.
    page.executeJavaScript("cambia(\"adios\")");
    System.out.println(page.getElementById("unDiv").getTextContent());
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) WebClient(com.gargoylesoftware.htmlunit.WebClient)

Aggregations

WebClient (com.gargoylesoftware.htmlunit.WebClient)182 Test (org.junit.Test)110 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)55 Page (com.gargoylesoftware.htmlunit.Page)33 TextPage (com.gargoylesoftware.htmlunit.TextPage)21 Before (org.junit.Before)20 HtmlSubmitInput (com.gargoylesoftware.htmlunit.html.HtmlSubmitInput)17 URL (java.net.URL)14 JsonObject (javax.json.JsonObject)13 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)13 WebResponse (com.gargoylesoftware.htmlunit.WebResponse)12 SpecAssertion (org.jboss.test.audit.annotations.SpecAssertion)11 HtmlSpan (com.gargoylesoftware.htmlunit.html.HtmlSpan)10 ReadContext (com.jayway.jsonpath.ReadContext)10 File (java.io.File)9 IOException (java.io.IOException)8 NicelyResynchronizingAjaxController (com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController)7 Test (org.junit.jupiter.api.Test)7 HtmlForm (com.gargoylesoftware.htmlunit.html.HtmlForm)6 DefaultCredentialsProvider (com.gargoylesoftware.htmlunit.DefaultCredentialsProvider)5