1

enter image description hereI'm trying to retrieve all the values after scrolling in a form of list. But i'm getting some of the repeated values. Please help.

Below is the code:

ArrayList<String> list1 = new ArrayList<String>();
        for(int a=0; a<=1; a++) {
            List<MobileElement> matchdayPoints = driver.findElements(By.id(""));
            for(MobileElement e : matchdayPoints) {
                list1.add(e.getAttribute("text"));
            }
            System.out.println(list1);
            scroll(driver, 0.5, 0.8, 0.5, 0.2);
        }
//below is the function for scroll

public static void scroll(AppiumDriver<MobileElement> driver, double start_xd, double start_yd, double end_xd, double end_yd) throws InterruptedException {
        Dimension dimension = driver.manage().window().getSize();
        int start_x = (int) (dimension.width * start_xd);
        int start_y = (int) (dimension.height * start_yd);
        
        int end_x = (int) (dimension.width * end_xd);
        int end_y = (int) (dimension.height * end_yd);
        
        TouchAction touch = new TouchAction(driver);
        touch.press(PointOption.point(start_x, start_y)).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1))).moveTo(PointOption.point(end_x, end_y)).release().perform();
        Thread.sleep(10000);
    }
3
  • Welcome. What would help is to show a screenshot of the app with this list and the underlying code (the mobile equivalent to the DOM)? What part of your code listed is failing? – Lee Jensen May 3 at 17:56
  • Can you share the page you are working on? Most probably you are re-finding the same elements. Maybe you need some Javascript to simply retrieve the values from the HTML, rather than using WebDriver directly. – João Farias May 3 at 18:00
  • I have added the screenshot of the application page from where I'm trying to retrieve the values using scroll. please help! – Sounak May 4 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.