4
www.meetme.com에서 메시지를 보내려고하지만이를 수행하는 방법을 알 수 없습니다. 댓글 영역에 메시지를 입력 할 수 있지만 보내기 버튼을 클릭해도 아무런 변화가 없습니다. 내가 도대체 뭘 잘못하고있는 겁니까? 로그인하고 로그인 버튼을 누르면 페이지가 바뀌고 모든 것이 정상입니다. 누구든지 아이디어 나 단서가 있습니까?HtmlUnit 버튼을 클릭하십시오.
HtmlPage htmlPage = null;
HtmlElement htmlElement;
WebClient webClient = null;
HtmlButton htmlButton;
HtmlForm htmlForm;
try{
// Create and initialize WebClient object
webClient = new WebClient(BrowserVersion.FIREFOX_17);
webClient.setCssEnabled(false);
webClient.setJavaScriptEnabled(false);
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setThrowExceptionOnScriptError(false);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setUseInsecureSSL(true);
webClient.getCookieManager().setCookiesEnabled(true);
/*webClient.setRefreshHandler(new RefreshHandler() {
public void handleRefresh(Page page, URL url, int arg) throws IOException {
System.out.println("handleRefresh");
}
});*/
htmlPage = webClient.getPage("http://www.meetme.com");
htmlForm = htmlPage.getFirstByXPath("//form[@action='https://ssl.meetme.com/login']");
htmlForm.getInputByName("username").setValueAttribute("[email protected]");
htmlForm.getInputByName("password").setValueAttribute("blah");
//Signing in
htmlButton = htmlForm.getElementById("login_form_submit");
htmlPage = (HtmlPage) htmlButton.click();
htmlPage = webClient.getPage("http://www.meetme.com/member/1234567890");
System.out.println("BEFORE CLICK");
System.out.println(htmlPage.asText());
//type message in text area
HtmlTextArea commentArea = (HtmlTextArea)htmlPage.getFirstByXPath("//textarea[@id='profileQMBody']");
commentArea.setText("Testing");
htmlButton = (HtmlButton) htmlPage.getHtmlElementById("profileQMSend");
htmlPage = (HtmlPage)htmlButton.click();
webClient.waitForBackgroundJavaScript(7000);
//The print is exactly the same as the BEFORE CLICK print
System.out.println("AFTER CLICK");
System.out.println(htmlPage.asText());
}catch(ElementNotFoundException e){
e.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
@mostly 작동했습니다! 고마워요! – altoids
환영합니다 :) 끔찍한 결과를 제거하려면 대답의 링크를 확인하십시오. (그 대답은 약간 구식 이었으므로 링크를 업데이트해야했습니다) –