0
List<WebElement> filter_icons = (ArrayList<WebElement>) driver.findElements(By.xpath(PropertyFile.read_obj("CONFIGURATION_MAJORMGMT_FILTER_LIST")));
filter_icons.size();
log.info("Data passed in Name Filter");

// filter EmailID
filter_icons.get(0).click();
Common.filter_textbox(driver, Name,By.xpath("//input[@id='filterText']"));
Common.click_filterbutton(driver,By.xpath("//button[text()='Apply Filter']"));

// filter Title
filter_icons.get(1).click();
Common.filter_textbox(driver, Value,By.xpath("//input[@id='filterText']"));
Common.click_filterbutton(driver,By.xpath("//button[text()='Apply Filter']"));

The issue with second filter click, it giving error,

java.lang.IndexOutOfBoundsException

The same code is working for other methods perfectly.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Deep
  • 1
  • 3
  • Possible duplicate of [What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?](https://stackoverflow.com/questions/5554734/what-causes-a-java-lang-arrayindexoutofboundsexception-and-how-do-i-prevent-it) – Guy Mar 14 '18 at 06:44

1 Answers1

1

The error {{IndexOutOfBoundsException: Index: 1, Size: 1 }} clearly says the size of the list is 1 (means you have item only at index 0) and you are trying to get an item at index 1, which does not exist.

You could do

for (WebElement ele : filter_icons) {
    ele.click();
    Common.filter_textbox(driver, Name,By.xpath("//input[@id='filterText']"));
    Common.click_filterbutton(driver,By.xpath("//button[text()='Apply Filter']"));
}
SP.
  • 85
  • 3
  • 13