HttpUnitを使用して、指定された URL に設計されたフォームの送信ボタンのクリックをシミュレートしています。(私は使用していますhttp://stu21.kntu.ac.ir/Login.aspx
)。次のコードを使用して、応答ページを取得します。
WebConversation conversation = new WebConversation();
WebRequest request = new GetMethodWebRequest("http://stu21.kntu.ac.ir/Login.aspx");
WebResponse response = conversation.getResource(request);
WebForm loginForm = response.getForms()[0]; //Form has been got successfully
request = loginForm.getRequest();
request.setParameter("txtusername", "8810103" );
request.setParameter("txtpassword", "8810103" );
response = conversation.getResponse( request ); //error while getting the .js files
フォームは正常に取得されますが、フォームに入力してフォームを送信しようとすると、次のようなエラーが発生しました。
getSubframeResponse(WebWindow.java:183) com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158) com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:199) com.meterware.httpunit.WebWindow Main.main(Main. java:76) スレッド「メイン」での例外 com.meterware.httpunit.ScriptException: Script 'var shuffleArray = new Array(); //var フィールド = ""; シャッフル = 関数 (o) { //v1.0 java:183) com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158) で com.meterware.httpunit.WebClient.getResponse(WebClient.java:122) で Main.main(Main.java:76) 例外スレッド「メイン」で com.meterware.httpunit.ScriptException: Script 'var shuffleArray = new Array(); //var フィールド = ""; シャッフル = 関数 (o) { //v1.0 java:183) com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158) で com.meterware.httpunit.WebClient.getResponse(WebClient.java:122) で Main.main(Main.java:76) 例外スレッド「メイン」で com.meterware.httpunit.ScriptException: Script 'var shuffleArray = new Array(); //var フィールド = ""; シャッフル = 関数 (o) { //v1.0
for (var j, x, l = o.length; l; j = parseInt(Math.random() * l), x = o[--l], o[l] = o[j], o[j] = x); for (var H = 0; H < 10; H++) { shuffleArray[H] = o[H]; } return o; }
///////////////////////////////キーパッドスクリプト関数 KeyPadInit() { alert("yes"); var乱数; var myNumbers = new Array();
for (jj = 0; jj < 10; jj++) { randomnumber = Math.floor(Math.random() * 10); while (IsInArray(myNumbers, randomnumber) == 1) { randomnumber = Math.floor(Math.random() * 10); }; switch (jj) { case 0: document.getElementById('btnSeven0').value = randomnumber; break; case 1: document.getElementById('btnSeven1').value = randomnumber; break; case 2: document.getElementById('btnSeven2').value = randomnumber; break; case 3: document.getElementById('btnSeven3').value = randomnumber; break; case 4: document.getElementById('btnSeven4').value = randomnumber; break; case 5: document.getElementById('btnSeven5').value = randomnumber; break; case 6: document.getElementById('btnSeven6').value = randomnumber; break; case 7: document.getElementById('btnSeven7').value = randomnumber; break; case 8: document.getElementById('btnSeven8').value = randomnumber; break; case 9: document.getElementById('btnSeven9').value = randomnumber; break; } myNumbers[myNumbers.length] = randomnumber; }
}
function IsInArray(objArray, num) { for (i = 0; i <= objArray.length - 1; i++) { if (objArray[i] == num) return 1; 0を返します。}
関数 ChangeStyle(objbtn, アクション) {
if (action == 'out') { objbtn.className = 'PadStyle'; } else if (action == 'over') { objbtn.className = 'PadStyleOver'; }
}
var inpId = 新しい配列(); var shuffleArray = new Array();
// * ** * ** * ** * ** * ** * ** * ***入力ボックスの数を計算* ** * ** * ** * ** * ** * ** * * * * ** * ***fillArray = 関数 () { inpId.splice(0, inpId.length - 1); 変数 i = 0; var InputsId = document.getElementsByTagName("入力"); for (var k = 0; k < InputsId.length; k++) { if ((InputsId[k].type == "text") || (InputsId[k].type == "password") || (InputsId [k].type == "checkbox") || (InputsId[k].type == "submit")) { if (!(InputsId[k].disabled)) { inpId[i++] = InputsId[k] ; } } } }
function AmountMaskE2(amount) { var i, j, mystring, flag;
if (amount == '') return ""; i = amount.length; mystring = ""; for (j = 0; j < i; j++) { if (amount.substring(j, j + 1) == ",") { flag = true; } } if (flag == true) { amount = DAmountMaskE(amount); } i = amount.length; if (i > 3) { for (j = i; j > 0; j = j - 3) { if (j > 3) { mystring = "," + amount.substring(j - 3, j) + mystring; } else { mystring = amount.substring(0, j) + mystring; } } return mystring; } else { return amount; }
}
function DAmountMaskE(amount) { var i, j, mystring, str; i = 量.長さ; mystring = "";
for (j = i; j >= 0; j -= 1) { str = amount.substring(j, j - 1); if (str != ",") { mystring = str + mystring; } } return mystring; }' failed: org.mozilla.javascript.EvaluatorException: illegal character at
com.meterware.httpunit.javascript.ScriptingEngineImpl.handleScriptException(ScriptingEngineImpl.java:64) com.meterware.httpunit.javascript.ScriptingEngineImpl.runScript(ScriptingEngineImpl.java:95) com.meterware.httpunit.scripting.ScriptableDelegate.runScript( ScriptableDelegate.java:88) com.meterware.httpunit.parsing.NekoDOMParser.runScript(NekoDOMParser.java:151) com.meterware.httpunit.parsing.ScriptFilter.getTranslatedScript(ScriptFilter.java:150) com.meterware.httpunit .parsing.ScriptFilter.endElement(ScriptFilter.java:131) org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:249) org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:367) ) org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1015) で org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:888) org.cyberneko.html.HTMLScanner$SpecialScanner.scan(HTMLScanner.java:2831) org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809) org .cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:478) org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:431) org.apache.xerces.parsers.XMLParser.parse(不明なソース) org .apache.xerces.parsers.DOMParser.parse(不明なソース) com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:48) com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:271) com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:1301) com.meterware.httpunit.WebResponse.getFrames(WebResponse.java:1285) com.meterware.httpunit.WebResponse.getFrameRequests(WebResponse.java:1024) com.meterware.httpunit.FrameHolder.updateFrames(FrameHolder.java:179) com.meterware.httpunit.WebWindow.updateFrameContents(WebWindow.java:315) com.meterware.httpunit.WebClient .updateFrameContents(WebClient.java:526) com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:201) com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183) com.meterware.httpunit. WebWindow.getResponse(WebWindow.java:158) com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:199) com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183) com.meterware.httpunit .WebWindow.getResponse(WebWindow.java:158) com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:199) com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183) で com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158) で com.meterware.httpunit.WebClient.getResponse(WebClient.java:122) で Main.main(Main.java) :76)
誰でも私の問題を解決するための解決策を教えてもらえますか?