我需要创建一个使用案例(使用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