我需要創建一個使用案例(使用Selenium),其中我通過瀏覽器使用Cookie發送HTTP調用,並在文本文件中捕獲返回值。使用Selenium從瀏覽器調用捕獲輸出
我需要做什麼,我已經在命令行中使用CURL來運行此操作,但是我們遇到了相同的問題,因此希望使用真實的UI瀏覽器進行驗證。
另一件事情是,我需要將URL放在測試文件中,我可以從中讀取併發送到瀏覽器。然後,對於每個電話,我需要捕獲cookie和標題相同。我有這樣的代碼/邏輯,可以有人詳細說明嗎?
---> read a file....
File aFile = new File("../blah.txt");
BufferedReader input = new BufferedReader(new FileReader(aFile));
String line = null; //not declared within while loop
while ((line = input.readLine()) != null){
callsel(line);
System.out.println(line);
}
--> call selenium .. Open the url.. Pass cookies
public void callsel(String url) {
selenium.open(url);
selenium.waitForPageToLoad("120000");
selenium.createCookie("","");
selenium.createCookie("","");
selenium.open(url);
selenium.waitForPageToLoad("120000");
---> ur page is open now..
}
}
嗨史蒂芬,我添加了一些更高的要求和一些代碼,你可以請檢查並詳細說明上述解決方案? – gagneet 2010-05-25 12:39:11