How to scroll and scroll to the last in Appium

I get several images from the API, and I don’t know the numbers, and now I want to test the interface in Android through Appium, and I want to scroll down to the last image. How can I do this, and also I don’t know what the name is from the API, so I can ScrollTo ("Name"), and also I can not spend the latter. Anyway?

+4
source share
4 answers

It is not possible to know for sure whether you scrolled the latter using appium, because there are no user interface reports for the scroll borders.

One way to find out that you have reached the end of the scroll without relying on the developers is to compare the list of all scrollview children each time you scroll. If all the children are exactly the same, you have reached the end. An example xpath for this would look like //android.widget.View[@content-desc="Your scrollview]//*that would capture all children and descendants. Once you have a list to compare, check the contents of all the child nodes. This will only work if there is something unique in these elements. If all the elements are completely common, there is nothing to compare, and this will not be reliable. Ask developers to add content descriptions or accessibility data to elements, if possible.

, . , , , . , .

, , , , scrollview .

+2

:

 public void scrollDown() {
    Dimension size = driver.manage().window().getSize();
    int x = size.getWidth() / 2;
    int starty = (int) (size.getHeight() * 0.60);
    int endy = (int) (size.getHeight() * 0.10);
    driver.swipe(x, starty, x, endy, 2000);
}
+1

, . driver.scrollToExact(list.get(list.size()).getAttribute("name"));

:

List<mobileElement> images = driver.findElementsByClass("<locator>");
driver.scrollToExact(images.get(images.size()).getAttribute("name")); 

driver.scrollToExact(images.get(images.size()).getText()); 
0
 @Test
    public void testScroll()throws Exception
    {
        for(int i=0;i<4;i++)
        {
            Thread.sleep(2000);
            if (driver.findElement(By.name("end_item")).isDisplayed())
            {
                driver.findElement(By.name("end_item")).click();
                break;
            }
            else
            {
                horizontalScroll();
            }

        }
    }
    public void verticalScroll()
    {
        size=driver.manage().window().getSize();
        int y_start=(int)(size.height*0.60);
        int y_end=(int)(size.height*0.30);
        int x=size.width/2;
        driver.swipe(x,y_start,x,y_end,4000);
    }

, http://qaautomated.blogspot.in/2016/02/how-to-do-horizontal-scroll-in-appium.html , .

0

Source: https://habr.com/ru/post/1630033/


All Articles