Search in sources :

Example 1 with HtmlAnchor

use of com.gargoylesoftware.htmlunit.html.HtmlAnchor in project javaee7-samples by javaee-samples.

the class UserTest method testLinkWithParam.

@Test
public void testLinkWithParam() throws IOException {
    HtmlAnchor anchor = (HtmlAnchor) page.getElementById("link2");
    assertTrue(anchor.getHrefAttribute().contains("faces/login.xhtml"));
    assertTrue(anchor.getHrefAttribute().contains("?name=Jack"));
    assertEquals("Login2", anchor.asText());
    HtmlPage output = anchor.click();
    assertEquals("HTTP GET (Login)", output.getTitleText());
}
Also used : HtmlAnchor(com.gargoylesoftware.htmlunit.html.HtmlAnchor) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Example 2 with HtmlAnchor

use of com.gargoylesoftware.htmlunit.html.HtmlAnchor in project javaee7-samples by javaee-samples.

the class UserTest method testLink.

@Test
public void testLink() throws IOException {
    HtmlAnchor anchor = (HtmlAnchor) page.getElementById("link1");
    assertTrue(anchor.getHrefAttribute().contains("faces/login.xhtml"));
    assertEquals("Login1", anchor.asText());
    HtmlPage output = anchor.click();
    assertEquals("HTTP GET (Login)", output.getTitleText());
}
Also used : HtmlAnchor(com.gargoylesoftware.htmlunit.html.HtmlAnchor) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Test(org.junit.Test)

Example 3 with HtmlAnchor

use of com.gargoylesoftware.htmlunit.html.HtmlAnchor in project javaee7-samples by javaee-samples.

the class UserTest method testLinkWithPreProcessParams.

@Test
public void testLinkWithPreProcessParams() {
    HtmlAnchor anchor = (HtmlAnchor) page.getElementById("link3");
    assertEquals("Login3", anchor.asText());
    assertTrue(anchor.getHrefAttribute().contains("faces/index2.xhtml"));
    assertTrue(anchor.getHrefAttribute().contains("?name=Jack"));
}
Also used : HtmlAnchor(com.gargoylesoftware.htmlunit.html.HtmlAnchor) Test(org.junit.Test)

Example 4 with HtmlAnchor

use of com.gargoylesoftware.htmlunit.html.HtmlAnchor in project blueocean-plugin by jenkinsci.

the class TryBlueOceanMenuTest method testOpenBlueOcean.

@Test
public void testOpenBlueOcean() throws IOException, SAXException {
    JenkinsRule.WebClient webClient = j.createWebClient();
    HtmlPage page = webClient.getPage(j.getInstance());
    HtmlAnchor anchor = page.getAnchorByText(Messages.BlueOceanUrlAction_DisplayName());
    Assert.assertEquals("/jenkins/blue/organizations/jenkins/pipelines/", anchor.getHrefAttribute());
    Assert.assertEquals("task-link", anchor.getAttribute("class"));
}
Also used : HtmlAnchor(com.gargoylesoftware.htmlunit.html.HtmlAnchor) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) JenkinsRule(org.jvnet.hudson.test.JenkinsRule) Test(org.junit.Test)

Aggregations

HtmlAnchor (com.gargoylesoftware.htmlunit.html.HtmlAnchor)4 Test (org.junit.Test)4 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)3 JenkinsRule (org.jvnet.hudson.test.JenkinsRule)1