내 대학 웹 사이트에 로그인하려고했지만 HTML 단위에 문제가있는 것으로 나타났습니다.HtmlUnit을 사용하여 로그인 웹 사이트
내 코드 :
WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_8);
webClient.setJavaScriptEnabled(false);
webClient.setThrowExceptionOnScriptError(false);
HtmlPage currentPage = webClient.getPage("http://www.oid.hacettepe.edu.tr/cgi-bin/menuindex.cgi");
HtmlForm form = currentPage.getForms().get(0); // forms correct
System.out.println(form.asXml());
HtmlTextInput name = form.getInputByName("login");
HtmlPasswordInput pass = form.getInputByName("passwd");
name.setValueAttribute("*****");
pass.setValueAttribute("*****");
HtmlSubmitInput button = form.getInputByName("SubmitName");
HtmlPage page2 = button.click();
System.out.println(page2.asText());
결과 :
Exception in thread "main" com.gargoylesoftware.htmlunit.ElementNotFoundException: elementName=[input] attributeName=[name] attributeValue=[login]
at com.gargoylesoftware.htmlunit.html.HtmlForm.getInputByName(HtmlForm.java:460)
at hacettepe.Hacettepe.main(Hacettepe.java:34)
Java Result: 1
는이 문제에 대한 내 생각에 어떤 문제가 있는지 설명 할 수 있습니까? 고마워.
asXml을 인쇄하고 있습니다. 그 산출물에서 당신이 기대하는 것을 보았습니까? –
http://pastebin.com/1nu7FX9m –
문제가 해결 되더라도 질문 문을 제거하고 말도 안되는 것으로 바꾸지 마십시오. –