Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何累积for循环中while循环的总执行量?_Java_Selenium_Selenium Webdriver - Fatal编程技术网

Java 如何累积for循环中while循环的总执行量?

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:

我想累积for循环中的条件while循环操作的总尝试次数,以重复测试while循环操作的稳定性。(使用Selenium框架)

尝试改变循环方法或设置变量,使用我能想到的所有方法,并通过社区查看,似乎没有人遇到类似的情况

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次的尝试”);