This is the entire bulk of the code.
for (int i = 0; i <= 1; i++, column++, row++) {
// read cell, input coordinates: (column, row)
Cell c1 = sh1.getCell(column, row);
Cell c2 = sh1.getCell(column + 1, row);
Cell c3 = sh1.getCell(column + 2, row);
Cell c4 = sh1.getCell(column + 3, row);
// return string content
String locationCode = c1.getContents();
String locationName = c2.getContents();
String description = c3.getContents();
String address = c4.getContents();
driver.findElement(By.id("tab7")).click();
driver.findElement(By.id("subtab2")).click();
driver.findElement(By.id("new")).click();
driver.findElement(By.id("ExtLocationCode")).clear();
driver.findElement(By.id("ExtLocationCode")).sendKeys(locationCode);
driver.findElement(By.id("LocationName")).clear();
driver.findElement(By.id("LocationName")).sendKeys(locationName);
driver.findElement(By.id("Description")).clear();
driver.findElement(By.id("Description")).sendKeys(description);
driver.findElement(By.id("address1")).clear();
driver.findElement(By.id("address1")).sendKeys(address);
driver.findElement(By.id("save")).click();
driver.findElement(By.id("actions")).click();
driver.findElement(By.id("save")).click();
}
After running it, it says: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
and it doesn't proceed to the next columns and rows of the cells in the excel file. What is wrong with my code?
rowsandcolumnsare there in the sheet?