可能显示 Javascript 测试支持
package htmlunitpoc;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
/**
*
* @author
*/
public class HtmlPoc {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
WebClient wc = new WebClient();
HtmlPage page = (HtmlPage) wc.getPage("http://www.google.com");
HtmlForm form = page.getFormByName("f");
HtmlSubmitInput button = (HtmlSubmitInput) form.getInputByName("btnG");
HtmlPage page2 = (HtmlPage) button.click();
}
}
但我得到:
2010 年 11 月 17 日下午 3:41:14 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl 通知警告:遇到过时的内容类型:'text/javascript'。构建成功(总时间:4 秒)
这无济于事,因为它不作为单元测试运行,并显示通过/失败等。
我正在使用 netbeans 6.9.1