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