请协助我使用eclipse设置htmlunit。我tryning填写的表格,并通过代码无法在eclipse中设置HTMLUNIT
这里提交这是我的代码
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
public class Ullas {
public static void main(String[] args) {
WebClient client = new WebClient();
try
{
HtmlPage currentPage = (HtmlPage)client.getPage("http://xx.com");
HtmlForm form = (HtmlForm) CurrentPage.getElementById("login_form");
final HtmlTextInput textField = form.getInputByName("nm");
textField.setValueAttribute("mak");
final HtmlSubmitInput button = form.getInputByName("submitbutton");
//currentPage = form.getAcceptAttribute();
button.click();
}
catch(Exception ex)
{
System.out.println("Some form of error happened !");
}
}
}
我没有包括所有的图书馆,但是当我运行它口口声声说应用的”用户操作等待'建筑工作区'太完整了'
+0
Eclipse可以有有时挂,没有明显的趋势原因(通常是因为记忆力)。尝试重新启动应用程序,如果你已经做到了;问题是否存在? –
+0
问题已解决,但您能解释我上面的代码应该如何工作意味着它应该弹出页面后表单submited或什么,因为当我执行我的代码。它什么都不做 –
+0
上面的代码打开一个网页,输入文本并点击提交按钮。我假设你已经将它指向了正确的域,那么它应该显示结果。 –