How to find linear frame layout size

can any one please help me,i am unable to get list of all images in that particular frame,the frame contains scroll view,in that particular frame i want to identify list of images and click one image randomly.can any one please help me.currently i can get only 4 images in that particular frame and randomly i am selecting one image.
please find the below image

no way. only scroll and count each.

Don’t know whether i understood your query or not. Here is my comment based on what i understood

Under scectin ‘All’ you have certain list of elements and wanted to know what are all the elements.

In Android we have certain limitation that whichever is displayed we can able to get only that count.

To know all the elements do perform scroll and loop it .

Thank you for your reply…please help me how to scroll up to ‘N’ of images in frame.please provide me sample code.

we do not have code - only you knows your app. we can only guide with pattern:

  1. count your elements what visible by unique data inside
  2. swipe
  3. count again your elements
    4.1) last element did not change -> this is END
    4.2) last element changed -> go to step 2

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

@nandini

  1. let’s discuss what means “count” :slight_smile:
    we assume that EACH of your product names is unique (if not - better do it). so “count” means:
    • create array of strings
    • check if new name exists in array -> NOT = add it into array
    • after scroll completed array.size() = number of your items.
  2. now with scroll. you scrolling in code SCREEN! but you need to scroll your layout where items are.
    to see where are you scrolling at enable in development menu:
    • Show touches
    • Show touch data

Thank you@aleksei.

  1. let’s discuss what means “count” :slight_smile:
    we assume that EACH of your product names is unique (if not - better do it). so “count” means:
  • create array of strings—Here my data contains both English and Arabic names.how can i create string array
  • check if new name exists in array -> NOT = add it into array----my scenario is scrolling is not based on the object name.identify of all the books present in the list and select random book for downloading
  • after scroll completed array.size() = number of your items.
  1. now with scroll. you scrolling in code SCREEN! but you need to scroll your layout where items are.
    to see where are you scrolling at enable in development menu:
  • Show touches
  • Show touch data

i am unable to focus on linear layout,where elements are present.
Dimension size = d.manage().window().getSize(); by using this i am getting only over all screen size i am unable to get the list of elements screen size.

can u please give me any solution or sample code for focus linear layout .

not linear but recycleview. lets make it better:

List<MobileElement> elementList = driver.findElements(MobileBy.id("scrollView1"));

scrollToDirection_iOS_XCTest(elementList.get(0), "l"); // where 0 is first 
scrollToDirection_iOS_XCTest(elementList.get(0), "r");

public boolean scrollToDirection_iOS_XCTest(MobileElement el, String direction) {
        // The main difference from swipe call with the same argument is that scroll will try to move
        // the current viewport exactly to the next/previous page (the term "page" means the content,
        // which fits into a single device screen)
        try {
            JavascriptExecutor js = (JavascriptExecutor) driver;
            HashMap<String, String> scrollObject = new HashMap<String, String>();
            if (direction.equals("d")) {
                scrollObject.put("direction", "down");
            } else if (direction.equals("u")) {
                scrollObject.put("direction", "up");
            } else if (direction.equals("l")) {
                scrollObject.put("direction", "left");
            } else if (direction.equals("r")) {
                scrollObject.put("direction", "right");
            }
            scrollObject.put("element", el.getId());
            js.executeScript("mobile:scroll", scrollObject);
            return true;
        } catch (Exception e) {
            return false;
        }
    }

Thank you@Aleksei…

List elementList = d.findElements(MobileBy.id(“scrollView1”));
System.out.println(“elements”+elementList);

when i am trying above syntax for my android application …
below output…but my test is passed.i am unable to understand why iam getting like this.can you please solve my problem
elements[[[AndroidDriver: on LINUX (c2795aef-1ec9-4e54-8c4b-737b4ec5a56e)] -> id: scrollView1], [[AndroidDriver: on LINUX (c2795aef-1ec9-4e54-8c4b-737b4ec5a56e)] -> id: scrollView1], [[AndroidDriver: on LINUX (c2795aef-1ec9-4e54-8c4b-737b4ec5a56e)] -> id: scrollView1], [[AndroidDriver: on LINUX (c2795aef-1ec9-4e54-8c4b-737b4ec5a56e)] -> id: scrollView1]]
PASSED: sign

Thank you advance

scrollView1 - is you container where items are. on page we see 4 scrollViews. first scrollView with some items others are empty. You are printing internal ids of that containers.

Thank you @Aleksei ,In my scenario list view contains recyclerview as child . so how can i focus the list item at particular index and moving the driver focus to particular recycleview view and scroll that recyclerview.i mean how can i focus on first scrollview.please help me

you should not move focus but scoll in correct scrollView. i gave example to scroll in first one.

/**

  • swipe to left
  • @param driver
  • @param during
  • @param num
    */
    public static void swipeToLeft(AppiumDriver driver,int during, int num) {
    int width = driver.manage().window().getSize().width;
    int height = driver.manage().window().getSize().height;
    for (int i = 0; i < num; i++) {
    driver.swipe(width * 3 / 4, height / 3, width / 4, height / 3, during);
    goSleep(3);
    }
    }

you can adjust the width /height

Thank You its working for me…