1
我已经开始学习HTTPUNIT并找到一个基本的例子。无法使用HTTPUNIT获取网页上的链接数量?
在这个例子中,它将访问这个site。 它将搜索包含HTTPUNIT的链接。它会打印HTTPUNIT上的链接数量。我在我的机器上试过这个例子,它工作。
WebConversation wc = new WebConversation();
WebRequest request = new GetMethodWebRequest("http://www.meterware.com");
WebResponse response = wc.getResponse(request);
WebLink httpunitLink = response.getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT, "HttpUnit");
response = httpunitLink.click();
System.out.println("The HttpUnit main page contains " + response.getLinks().length + " links");
我现在已经改变了代码
WebConversation wc = new WebConversation();
WebRequest request = new GetMethodWebRequest("http://www.google.com");
WebResponse response = wc.getResponse(request);
WebLink httpunitLink = response.getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT, "News");
response = httpunitLink.click();
System.out.println("The HttpUnit main page contains " + response.getLinks().length + " links");
现在它是给下面的错误。
ConversionError: The undefined value has no properties. (httpunit; line 4)
为什么无法访问Google新闻并获取链接数?
预先感谢您。
更具体地说,“WebDriver”是Selenium的一部分。 – djangofan 2012-03-31 16:24:17
@Devon它是否像QTP? “”快速测试专业“ – vikiiii 2012-03-31 16:34:14
@vikii概念上相似,Selenium Webdriver钩入浏览器让你控制它与网站的交互 – 2012-03-31 18:04:54