use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class ServletConversationTest method testPost.
@Test
public void testPost() throws Exception {
WebClient client = new WebClient();
// begin conversation
TextPage initialPage = client.getPage(getPath("/begin", null));
String content = initialPage.getContent();
assertTrue(content.contains("message: Hello"));
assertTrue(content.contains("transient: false"));
String cid = getCid(content);
// submit a form
{
HtmlPage form = client.getPage(url.toString() + "/message.html");
getFirstMatchingElement(form, HtmlTextInput.class, "message").setValueAttribute("Hola!");
getFirstMatchingElement(form, HtmlTextInput.class, "cid").setValueAttribute(cid);
TextPage page = getFirstMatchingElement(form, HtmlSubmitInput.class, "submit").click();
assertTrue(page.getContent().contains("message: Hola!"));
assertTrue(page.getContent().contains("cid: [" + cid + "]"));
assertTrue(page.getContent().contains("transient: false"));
}
// verify conversation state
{
TextPage page = client.getPage(getPath("/display", cid));
assertTrue(page.getContent().contains("message: Hola!"));
assertTrue(page.getContent().contains("cid: [" + cid + "]"));
assertTrue(page.getContent().contains("transient: false"));
}
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class Weld1262Test method testConversationNotPropagatedByFacesRedirect.
@Test
public void testConversationNotPropagatedByFacesRedirect() throws Exception {
HtmlPage main = startConversation();
HtmlPage road = getFirstMatchingElement(main, HtmlSubmitInput.class, "redirect").click();
assertEquals("Guide is not active", getFirstMatchingElement(road, HtmlSpan.class, "guideMessage").getTextContent());
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class Weld1262Test method startConversation.
public HtmlPage startConversation() throws Exception {
WebClient client = new WebClient();
HtmlPage main = client.getPage(url.toString().concat("crossroad.jsf"));
main = getFirstMatchingElement(main, HtmlSubmitInput.class, "begin").click();
String cid = getFirstMatchingElement(main, HtmlSpan.class, "cid").getTextContent();
assertTrue(Integer.valueOf(cid) > 0);
return main;
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project joynr by bmwcarit.
the class ChannelServiceTestUtils method getChannelIdsOnChannelsHtml.
/**
* Returns a list of channel IDs that are displayed on the channels.html page for the bounce proxy.
*
* @param webClient
* @param url
* @return
* @throws Exception
*/
public static List<String> getChannelIdsOnChannelsHtml(WebClient webClient, String url) throws Exception {
HtmlPage page = webClient.getPage(url);
webClient.waitForBackgroundJavaScript(2000);
DomElement channelsTable = page.getElementById("channels");
List<String> channelIds = new LinkedList<String>();
for (DomElement channelsTableRows : channelsTable.getChildElements()) {
if (channelsTableRows.getTagName().equals("tbody")) {
for (DomElement channelRows : channelsTableRows.getChildElements()) {
String channelId = channelRows.getChildNodes().get(0).getTextContent();
if (isProperChannelId(channelId)) {
channelIds.add(channelId);
}
}
}
}
return channelIds;
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project shiro by apache.
the class ContainerIntegrationIT method logIn.
@Test
public void logIn() throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {
HtmlPage page = webClient.getPage(getBaseUri() + "login.jsp");
HtmlForm form = page.getFormByName("loginform");
form.<HtmlInput>getInputByName("username").setValueAttribute("root");
form.<HtmlInput>getInputByName("password").setValueAttribute("secret");
page = form.<HtmlInput>getInputByName("submit").click();
// This'll throw an expection if not logged in
page.getAnchorByHref("/logout");
}
Aggregations