Java 如何累积for循环中while循环的总执行量?
我想累积for循环中的条件while循环操作的总尝试次数,以重复测试while循环操作的稳定性。(使用Selenium框架) 尝试改变循环方法或设置变量,使用我能想到的所有方法,并通过社区查看,似乎没有人遇到类似的情况Java 如何累积for循环中while循环的总执行量?,java,selenium,selenium-webdriver,Java,Selenium,Selenium Webdriver,我想累积for循环中的条件while循环操作的总尝试次数,以重复测试while循环操作的稳定性。(使用Selenium框架) 尝试改变循环方法或设置变量,使用我能想到的所有方法,并通过社区查看,似乎没有人遇到类似的情况 public static void main(String[] args) throws Exception { for (int loop = 1; loop <= 10; loop++) { System.out.println("Loop count:
public static void main(String[] args) throws Exception {
for (int loop = 1; loop <= 10; loop++) {
System.out.println("Loop count: " + loop);
boolean retry = true;
int i = 1;
while (retry == true) {
int t = i++;
//...
System.out.println("Test case 1 - Start Run " + t);
try {
// my testing script of actions
System.out.println("Test case 1 - Run Success, finished by "
+ t + " execution(s)");
retry = false;
break;
} catch (Exception e) {
System.out.println("Test case 1 - Run "
+ t + " Failed, retry...");
}
driver.quit();
}
}
}
publicstaticvoidmain(字符串[]args)引发异常{
对于(int loop=1;loop为什么不将总数保持在两个循环之外
int totalCount = 0;
for (int i = 0; i < 10; i ++) {
while (retry) {
totalCount ++;
// do your thing
}
}
System.out.println("Took " + totalCount + " attempts to get 10 successfully");
inttotalcount=0;
对于(int i=0;i<10;i++){
while(重试){
totalCount++;
//做你的事
}
}
System.out.println(“获取”+totalCount+“成功获取10次的尝试”);