我正在尝试使用 Selenium Java/Firefox Eclipse 插件对 webapp 进行自动化测试。我正在尝试付款,然后删除 cookie,以删除所有存储的信息。由于某种原因,这不起作用。
public void validationCards(BufferedWriter out){
outFile = out;
ArrayList<String> methodList = new ArrayList<String>();
methodList.add("validationVisaFrench");
methodList.add("validationMCFrench");
methodList.add("validationDiscoverFrench");
methodList.add("validationDinerClubFrench");
methodList.add("validationJCBFrench");
Method method = null;
for(String testToRun:methodList){
try{
method = this.getClass().getMethod(testToRun);
}catch(NoSuchMethodException e){
System.out.println("This failed horribly");
e.printStackTrace();
}catch(RuntimeException ex){
ex.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}
try{
PPSCTests tempObj = this;
this.testDriver.manage().deleteAllCookies();
method.invoke(tempObj);
this.testDriver.manage().deleteAllCookies();
}catch (Exception e) {
System.out.println("Cant invoke method for shits and giggles");
e.printStackTrace();
}
}
}
这是我正在尝试运行的测试之一的示例:
public void validationMCFrench(){
System.out.println("MC French Stored Card");
this.testDriver.manage().deleteAllCookies();
payment("5555555555554444", "frenchQuery");
testSelenium.waitForPageToLoad("20000");
String source = Jsoup.parse(testDriver.getPageSource()).text();
System.out.println("validationMCFrench: "+source);
successOrFail(source, "validationMCFrench", "Example");
this.testDriver.manage().deleteAllCookies();
}
但似乎实际上并没有删除任何 cookie。我有点卡住了。任何帮助将不胜感激。