use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class Weld1262Test method testConversationPropagatedByNavigationHandler.
@Test
public void testConversationPropagatedByNavigationHandler() throws Exception {
HtmlPage main = startConversation();
HtmlPage road = getFirstMatchingElement(main, HtmlSubmitInput.class, "guide").click();
assertEquals("Guide is active", getFirstMatchingElement(road, HtmlSpan.class, "guideMessage").getTextContent());
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class NamedProducerTest method testNamedProducerFieldLoosesValues.
/*
* description = "WELD-404"
*/
@Test
public void testNamedProducerFieldLoosesValues() throws Exception {
WebClient client = new WebClient();
HtmlPage page = client.getPage(getPath("/home.jsf"));
// Check the page rendered ok
HtmlSubmitInput saveButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "saveButton");
HtmlTextInput employeeFieldName = getFirstMatchingElement(page, HtmlTextInput.class, "employeeFieldName");
HtmlTextInput employeeMethodName = getFirstMatchingElement(page, HtmlTextInput.class, "employeeMethodName");
Assert.assertNotNull(employeeFieldName);
Assert.assertNotNull(employeeMethodName);
Assert.assertNotNull(saveButton);
employeeFieldName.setValueAttribute("Pete");
employeeMethodName.setValueAttribute("Gavin");
saveButton.click();
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project core by weld.
the class NamedProducerTest method testNamedProducerWorks.
/*
* description = "forum post"
*/
@Test
public void testNamedProducerWorks() throws Exception {
WebClient client = new WebClient();
client.setThrowExceptionOnFailingStatusCode(false);
HtmlPage page = client.getPage(getPath("/view.jsf"));
// Check the page rendered ok
Assert.assertNotNull(getFirstMatchingElement(page, HtmlSubmitInput.class, "saveButton"));
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project spring-boot-quick by vector4wang.
the class InnotreeService method main.
public static void main(String[] args) throws IOException {
// 创建WebClient
final WebClient webClient = new WebClient();
webClient.getOptions().setJavaScriptEnabled(false);
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setRedirectEnabled(true);
webClient.getOptions().setThrowExceptionOnScriptError(false);
// webClient.getOptions().set
webClient.getOptions().setTimeout(5000);
//
// // 获取页面
// HtmlPage page = webClient.getPage("http://www.innotree.cn/indexprocoo/search.html?keyword=%E5%85%AB%E7%88%AA");
// webClient.waitForBackgroundJavaScript(10000);
// // 获得name为"session_key"的html元素
// // HtmlElement usernameEle = page.getElementByName("session_key");
// // // 获得id为"session_password"的html元素
// // HtmlElement passwordEle = (HtmlElement) page.getElementById("session_password-login");
// // usernameEle.focus(); // 设置输入焦点
// // usernameEle.type(name);
// // passwordEle.focus(); // 设置输入焦点
// //
// // passwordEle.type(password);
// System.out.println(page.getWebResponse().getContentAsString());
String keyEncode = URLEncoder.encode("八爪", "UTF-8");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
WebRequest webRequest = new WebRequest(new URL("http://www.innotree.cn/collectlog/info.ajax"));
webRequest.setHttpMethod(HttpMethod.POST);
JSONObject params = new JSONObject();
params.put("source_type", "pc");
params.put("collect_type", "click");
params.put("collect_key", "search");
params.put("collect_type", "八爪");
params.put("collect_id", "");
params.put("u_request_url", "http://www.innotree.cn/indexprocoo/search.html?keyword=" + keyEncode);
params.put("u_referer_url", "http://www.innotree.cn/indexprocoo/search.html?keyword=" + keyEncode);
params.put("u_agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36");
params.put("gen_time", format.format(new Date()));
params.put("collect_page", "SearchList");
JSONObject nj = new JSONObject();
nj.put("json", params);
webRequest.setAdditionalHeader("Accept", "application/json, text/javascript, */*; q=0.01");
webRequest.setAdditionalHeader("Accept-Encoding", "gzip, deflate");
webRequest.setAdditionalHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
webRequest.setAdditionalHeader("Connection", "keep-alive");
webRequest.setAdditionalHeader("Host", "www.innotree.cn");
webRequest.setAdditionalHeader("Cookie", "_user_identify_=38e78465-ca98-39a1-a411-d22034ad31af; JSESSIONID=aaaJR4Oz2351xh_LAPKZv; Hm_lvt_37854ae85b75cf05012d4d71db2a355a=1498484735,1498485012; Hm_lpvt_37854ae85b75cf05012d4d71db2a355a=1498486706");
webRequest.setAdditionalHeader("Origin", "http://www.innotree.cn");
webRequest.setAdditionalHeader("Referer", "http://www.innotree.cn/indexprocoo/search.html?keyword=" + keyEncode);
webRequest.setAdditionalHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36");
webRequest.setAdditionalHeader("X-Requested-With", "XMLHttpRequest");
// webRequest.setAdditionalHeader("Content-Length",""+params.toString().length());
System.out.println(nj.toString());
// webRequest.setRequestBody("REQUESTBODY");
webRequest.setRequestParameters(new ArrayList());
webRequest.getRequestParameters().add(new NameValuePair("json", params.toString()));
Page page = webClient.getPage(webRequest);
// webRequest.getre
page = webClient.getPage("http://www.innotree.cn/indexprocoo/search.html?keyword=" + keyEncode);
System.out.println(page.getWebResponse().getContentAsString());
}
use of com.gargoylesoftware.htmlunit.html.HtmlPage in project jackrabbit by apache.
the class TomcatIT method testTomcat.
public void testTomcat() throws Exception {
HtmlPage page = client.getPage(url);
assertEquals("Content Repository Setup", page.getTitleText());
page = submitNewRepositoryForm(page);
assertEquals("Content Repository Ready", page.getTitleText());
page = page.getAnchorByText("home").click();
assertEquals("Apache Jackrabbit JCR Server", page.getTitleText());
}
Aggregations