Search in sources :

Example 1 with HtmlTable

use of com.gargoylesoftware.htmlunit.html.HtmlTable in project selenium_java by sergueik.

the class JenkinsConfigurationPage method getSecurityMatrix.

private HtmlTable getSecurityMatrix() {
    // enable security
    final HtmlElement useSecurity = configForm.getInputByName("_.useSecurity");
    try {
        useSecurity.click();
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
    // use matrix-based security
    final List<HtmlInput> authorizationInputs = configForm.getInputsByName("authorization");
    HtmlInput useMatrixSecurityRadioBtn = null;
    for (final HtmlInput input : authorizationInputs) {
        if (input.getValueAttribute().equals("3")) {
            useMatrixSecurityRadioBtn = input;
            break;
        }
    }
    try {
        useMatrixSecurityRadioBtn.click();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return (HtmlTable) configForm.getOwnerDocument().getElementById("hudson-security-GlobalMatrixAuthorizationStrategy");
}
Also used : HtmlTable(com.gargoylesoftware.htmlunit.html.HtmlTable) HtmlElement(com.gargoylesoftware.htmlunit.html.HtmlElement) IOException(java.io.IOException) HtmlInput(com.gargoylesoftware.htmlunit.html.HtmlInput)

Example 2 with HtmlTable

use of com.gargoylesoftware.htmlunit.html.HtmlTable in project testcases by coheigea.

the class OIDCTest method loginToClientsPage.

// Runs as BeforeClass: Login to the OIDC Clients page + create a new client
private static void loginToClientsPage(String rpPort, String oidcPort, String idpPort) throws Exception {
    String url = "https://localhost:" + oidcPort + "/fediz-oidc/console/clients";
    String user = "alice";
    String password = "ecila";
    // Login to the client page successfully
    WebClient webClient = setupWebClient(user, password, idpPort);
    HtmlPage loginPage = login(url, webClient);
    final String bodyTextContent = loginPage.getBody().getTextContent();
    Assert.assertTrue(bodyTextContent.contains("Registered Clients"));
    String clientUrl = "https://localhost:" + rpPort + "/fedizdoubleit/auth/rp/complete";
    // Now try to register a new client
    HtmlPage registeredClientPage = registerNewClient(webClient, url, "consumer-id", clientUrl, clientUrl);
    String registeredClientPageBody = registeredClientPage.getBody().getTextContent();
    Assert.assertTrue(registeredClientPageBody.contains("Registered Clients"));
    Assert.assertTrue(registeredClientPageBody.contains("consumer-id"));
    HtmlTable table = registeredClientPage.getHtmlElementById("registered_clients");
    storedClientId = table.getCellAt(1, 1).asText().trim();
    Assert.assertNotNull(storedClientId);
    // Now get the Client Secret
    final HtmlPage clientPage = webClient.getPage(url + "/" + storedClientId);
    HtmlTable clientPageTable = clientPage.getHtmlElementById("client");
    storedClientSecret = clientPageTable.getCellAt(1, 2).asText().trim();
    Assert.assertNotNull(storedClientSecret);
    webClient.close();
}
Also used : HtmlTable(com.gargoylesoftware.htmlunit.html.HtmlTable) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) WebClient(com.gargoylesoftware.htmlunit.WebClient)

Example 3 with HtmlTable

use of com.gargoylesoftware.htmlunit.html.HtmlTable in project sling by apache.

the class MetricWebConsolePluginTest method assertTable.

private void assertTable(String name, HtmlPage page) {
    HtmlTable table = page.getHtmlElementById(name);
    assertNotNull(table);
    //1 for header and 1 for actual metric row
    assertThat(table.getRowCount(), greaterThanOrEqualTo(2));
}
Also used : HtmlTable(com.gargoylesoftware.htmlunit.html.HtmlTable)

Example 4 with HtmlTable

use of com.gargoylesoftware.htmlunit.html.HtmlTable in project JSCover by tntim96.

the class HtmlUnitServerBranchAndFunctionTest method shouldDisplayCoverageInformationOnSourcePage.

@Test
@Override
public void shouldDisplayCoverageInformationOnSourcePage() throws IOException {
    HtmlPage page = webClient.getPage("http://localhost:9001/jscoverage.html?" + getTestUrl());
    HtmlPage frame = (HtmlPage) page.getFrameByName("browserIframe").getEnclosedPage();
    verifyTotal(webClient, page, 15);
    page.getAnchorByText("/example/script.js").click();
    webClient.waitForBackgroundJavaScript(2000);
    HtmlTable sourceTable = (HtmlTable) page.getElementById("sourceTable");
    verifySource(sourceTable, 11, 0, "  else if (element.id === 'radio2') {", "Condition never evaluated         :\telement.id === 'radio2'", "r");
    verifySource(sourceTable, 12, 0, "    message = getMessage(2);", null, "");
    frame.getHtmlElementById("radio2").click();
    webClient.waitForBackgroundJavaScript(500);
    verifyTotal(webClient, page, 68, 25, 66);
    page.getAnchorByText("/example/script.js").click();
    webClient.waitForBackgroundJavaScript(2000);
    sourceTable = (HtmlTable) page.getElementById("sourceTable");
    verifySource(sourceTable, 11, 1, "  else if (element.id === 'radio2') {", "Condition never evaluated to false:\telement.id === 'radio2'", "r");
    verifySource(sourceTable, 12, 1, "    message = getMessage(2);", null, "");
    frame.getHtmlElementById("radio4").click();
    webClient.waitForBackgroundJavaScript(500);
    verifyTotal(webClient, page, 89, 62, 100);
    page.getAnchorByText("/example/script.js").click();
    webClient.waitForBackgroundJavaScript(2000);
    sourceTable = (HtmlTable) page.getElementById("sourceTable");
    verifySource(sourceTable, 11, 2, "  else if (element.id === 'radio2') {", null, "g");
    verifySource(sourceTable, 12, 1, "    message = getMessage(2);", null, "");
}
Also used : HtmlTable(com.gargoylesoftware.htmlunit.html.HtmlTable) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Example 5 with HtmlTable

use of com.gargoylesoftware.htmlunit.html.HtmlTable in project JSCover by tntim96.

the class HtmlUnitServerTest method shouldDisplayCoverageInformationOnSourcePage.

@Test
public void shouldDisplayCoverageInformationOnSourcePage() throws IOException {
    HtmlPage page = webClient.getPage("http://localhost:9001/jscoverage.html?" + getTestUrl());
    HtmlPage frame = (HtmlPage) page.getFrameByName("browserIframe").getEnclosedPage();
    verifyTotal(webClient, page, 15);
    page.getAnchorByText("/example/script.js").click();
    webClient.waitForBackgroundJavaScript(2000);
    HtmlTable sourceTable = (HtmlTable) page.getElementById("sourceTable");
    verifySource(sourceTable, 11, 0, "  else if (element.id === 'radio2') {");
    verifySource(sourceTable, 12, 0, "    message = getMessage(2);");
    frame.getHtmlElementById("radio2").click();
    webClient.waitForBackgroundJavaScript(500);
    verifyTotal(webClient, page, 68, 0, 0);
    page.getAnchorByText("/example/script.js").click();
    webClient.waitForBackgroundJavaScript(2000);
    sourceTable = (HtmlTable) page.getElementById("sourceTable");
    verifySource(sourceTable, 11, 1, "  else if (element.id === 'radio2') {");
    verifySource(sourceTable, 12, 1, "    message = getMessage(2);");
}
Also used : HtmlTable(com.gargoylesoftware.htmlunit.html.HtmlTable) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Aggregations

HtmlTable (com.gargoylesoftware.htmlunit.html.HtmlTable)6 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)3 Test (org.junit.Test)2 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)1 HtmlInput (com.gargoylesoftware.htmlunit.html.HtmlInput)1 HtmlTableRow (com.gargoylesoftware.htmlunit.html.HtmlTableRow)1 IOException (java.io.IOException)1