【发布时间】:2012-09-10 08:54:44
【问题描述】:
我正在尝试学习 HTTPUnit,并阅读了 http://httpunit.sourceforge.net/doc/cookbook.html 中提到的食谱
但是当我尝试这个非常简单的代码时
package httpUnit.test;
import java.io.IOException;
import org.xml.sax.SAXException;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebLink;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
/*** Hello world!**/
public class App{
public static void main( String[] args ) throws IOException, SAXException {
System.out.println( "Trying HTPUnit library");
WebConversation wc = new WebConversation();
WebRequest req = new GetMethodWebRequest("http://localhost:8080/proof/demo.html");
WebResponse resp = wc.getResponse(req);
/* WebLink[ ] link = resp.getLinks();
for (int i=0; i<link.length; i++) {
System.out.println(link[i].getText());
}
System.out.println(link.length);
*/
}
};
我收到以下错误:
TypeError: undefined is not a function. (httpunit; line 15)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:597)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:557)
Error continues.....
和
Exception in thread "main" com.meterware.httpunit.ScriptException: Script '/*!
* jQuery JavaScript Library v1.6
* http://jquery.com/
有人可以找出可能是什么问题。我无法理解。我已经创建了具有来自http://mvnrepository.com/artifact/httpunit/httpunit/1.6.1 的 maven 依赖项的 maven 项目
我在tomcat的proof文件夹中托管了demo.html,它在浏览器中可以正常打开。
【问题讨论】:
-
PS:我没有发布完整的错误,因为它会增加问题的长度。如果有人说,我会
-
是不是因为HTML页面也有一些javascript代码??