Thank you Aleksei.below is my code previously i tried with this code to count elements
1.count your elements what visible by unique data inside
List list1 = d.findElements(By.id(com.semanoor.manahij:id/scrollView1));
list1.size();
System.out.println("element is "+list1.size());
System.out.println("element is "+list1.size());
Random r = new Random();
int randomproduct=r.nextInt(list1.size()+0);
System.out.println("id is"+randomproduct);
//list1.get(randomproduct).click();
return list1.get(randomproduct);
using above code i got 4 elements for particular linear layout.
As ur suggestion i try to swipe elements using below code,but horizontal swiping is not working on my page
2) swipe
Dimension size = d.manage().window().getSize();
System.out.println(size);
int x1 = (int) (size.width * 0.20);
int x2 = (int) (size.width * 0.80);
TouchAction action = new TouchAction((MobileDriver)d);
WebElement ele1 = (WebElement) d.findElementsById("com.semanoor.manahij:id/scrollView1").get(1);
action.longPress(ele1).moveTo(element).release().perform();
can any one please correct my code for right to left swiping