title: Index Out of Bounds Looping through WebElement List
body: <p>I am trying to set web elements value to 0 or null. Basically i want to clear the value of the web element so it can store another element. Currently i get stack trace information saying : java.lang.IndexOutOfBoundsException: Index: 1, Size: 1. I know that this mean that there is a value that is still there and it needed to be cleared before it can be used again.</p>
  
  <p>basically i am trying to do this 
  1 get list element value
  2 loop
  3 clear the value
  4 repeat steps 1 -3 untill the condition is true and i break the loop.</p>
  
  <p>my code is below. it works but only goes around 1 time.</p>
  
  <pre><code> for (int x = 0; x &lt; 100; x++) {
  
   String PreviewStatus = "//table[@id='cppProcessInfoTable_rows_table']//tr[@id='cppProcessInfoTable_row_0']/td[starts-with(@id,'cppProcessInfoTable_row_0_cell_2')]";
   List &lt; WebElement &gt; Status = driver.findElements(By.xpath(PreviewStatus));
   WebElement status = Status.get(x);
   String pstatus = status.getText().trim();
  
  
   String Status1 = "Completed";
   String Status2 = "Sucessfull";
   String Status3 = "Payroll Delayed";
   String Status4 = "Error";
  
   WebElement CalcPreviewPayroll = driver.findElement(By.xpath("//*[contains(@id,'cppBatch_title')]"));
  
   if (CalcPreviewPayroll.isDisplayed() &amp;&amp; pstatus.equals(Status1) || pstatus.equals(Status2) || pstatus.equals(Status3) || pstatus.equals(Status4)) {
    PS_OBJ_CycleData.Close(driver).click();
    break;
   }
  
   if (!CalcPreviewPayroll.isDisplayed()) {
    break;
   }
   System.out.println("\n" + "status " + pstatus);
   Status = null;
  
  }       }
  </code></pre>