Not able check multiple images from list

I want to select 5 images from list but it works only for 1 image. My code :

for(int i=0;i<=10;i++)
 {
	 
	 List<WebElement> E = driver.findElements(By.xpath("//android.widget.GridView//android.widget.ImageView[1]"));
	 E.size();
	driver.findElement(By.xpath("//android.widget.GridView//android.widget.ImageView[1]")).click();

}

When I debug , it shows me E.size = 12 , I am really wonder that how? Also I have tried by taking “count” variable to go through images one by one but that is also not working.

I think all image has same xpath and does that create problem?

Also Can I find and click on element by getting its “bound values” means based in Co-ordinates? if yes then how?**

Also check attached screenshot for more info.

Your For loop makes no sense.

Try below code… It might help you.

List e=driver.findElements(By.xpath(""));

    for(int i=0;i<5;i++){                          // If you want to click first 5 images 
        e.get(i).click();
    }
1 Like

List e=driver.findElements(By.xpath(""));

    for(int i=0;i<5;i++){
        e.get(i).click();
    }
1 Like

Yeah , you looks right…I have changed code as per your view and its working…Thank a lot…