是否有人知道如何使用HtmlUnit,Java提交此表單?使用HtmlUnit提交表單
<form name="sendSmsForm" method="POST" action="/talkmore3/servlet/SendSmsFromSelfcare" onsubmit="return checkBeforeSubmit();">
<input type="hidden" value name="message1" id="message1"/>
<input type="hidden" value name="list" id="list"/>
<table border="0" width="560">
<tbody>
<tr>
<td>
<div id="ContactListPanel">
<iframe height="425" width="560" frameborder="0" scrolling="no" id="ContactListFrame" name="ContactListFrame" src="/talkmore3/servlet/ManageContactList">
</iframe>
</div>
</td>
</tr>
<tr align="left">
<td colspan="2" align="left">
<div class="button_green" style="width: 114px; float: left;margin-left: 130px">
<a href="javascript:sendSMS();" title="Send SMS">
<span>
Send SMS
</span>
</a>
</div>
</td>
</tr>
</tbody>
</table>
</form>
我已經試過這一點:
HtmlForm form = page.getFormByName("sendSmsForm");
form.getInputByName("list").setValueAttribute("99999999");
form.getInputByName("message1").setValueAttribute("test");
HtmlAnchor submit = page.getFirstByXPath("//a[@href='javascript:sendSMS();']");
submit.click();
但好像它沒有得到輸入的值..
試圖通過索引號而不是表單名稱獲得表格 – Arya