Scrolling is not working on nested scrollview c# android


#1

Hi everyone!

I have problem with scrolling view in android app.
Code is performed properly but screen is not moved. I thing that the problem could be related with fact that it is nested scroll view which alows scrolling and swipeing.

Have any one deal with it? Is there any workaroud? Or maybe Is there any hot fix on the developers side?

This is what I know for now:

  • appium tells me that scroll was performed properly
  • this methods for scrolling are working on another screens in this app
  • the coordinates are correct
  • is not working neither in 1.8 nor in 1.9 appium version

I use native android app (api 23) & VS 2017 & windows 10.

C# CODE
public static void Scroll(this AppiumDriver driver, MoveDirection direction)
{
var scrollElement = driver.FindElementByClassName(“android.widget.ScrollView”);
var windowSize = driver.Manage().Window.Size;
var upperPoint = new Point((int)(windowSize.Width * 0.3), (int)(windowSize.Height * 0.55));
var middlePoint = new Point((int)(windowSize.Width * 0.3), (int)(windowSize.Height * 0.75));

            switch (direction)
            {
                case MoveDirection.down:
                    Move(driver, scrollElement, middlePoint, upperPoint);
                    break;

                case MoveDirection.up:
                    Move(driver, scrollElement, upperPoint, middlePoint);
                    break;
            }
        }

        private static void Move(this AppiumDriver<IWebElement> driver, IWebElement elementToMove, Point startMove, Point endMove)
        {
            var action = new TouchAction(driver)
                    .Press(elementToMove, startMove.X, startMove.Y)
                    .Wait(500)
                    .MoveTo(elementToMove, endMove.X, endMove.Y)
                    .Release();

            action.Perform();
        }

APPIUM LOGS - only scrolling fragment

–> POST /wd/hub/session/29ecf89f-5d08-42c6-95dc-7ac16f74e4a6/touch/perform
[HTTP] {“actions”:[{“action”:“press”,“options”:{“element”:“45”,“x”:324,“y”:1332}},{“action”:“wait”,“options”:{“ms”:500}},{“action”:“moveTo”,“options”:{“element”:“45”,“x”:324,“y”:976}},{“action”:“release”}]}
[debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{“action”:“press”,“options”:{“element”:“45”,“x”:324,“y”:1332}},{“action”:“wait”,“options”:{“ms”:500}},{“action”:“moveTo”,“options”:{“element”:“45”,“x”:324,“y”:976}},{“action”:“release”}],“29ecf89f-5d08-42c6-95dc-7ac16f74e4a6”]
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:getLocation”,“params”:{“elementId”:“45”}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:getLocation”,“params”:{“elementId”:“45”}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getLocation
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:0,“value”:{“x”:0,“y”:585}}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:getSize”,“params”:{“elementId”:“45”}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:getSize”,“params”:{“elementId”:“45”}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getSize
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:0,“value”:{“width”:1080,“height”:1007}}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:getLocation”,“params”:{“elementId”:“45”}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:getLocation”,“params”:{“elementId”:“45”}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getLocation
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:0,“value”:{“x”:0,“y”:585}}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:swipe”,“params”:{“startX”:324,“startY”:1332,“endX”:324,“endY”:976,“steps”:14,“elementId”:“45”}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:swipe”,“params”:{“startX”:324,“startY”:1332,“endX”:324,“endY”:976,“steps”:14,“elementId”:“45”}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: swipe
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element bounds: [0,585][1080,1592]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element bounds: [0,585][1080,1592]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Swiping from [x=324.0, y=1917.0] to [x=324.0, y=1561.0] with steps: 14
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:0,“value”:true}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Responding to client with driver.performTouch() result: true
[HTTP] <-- POST /wd/hub/session/29ecf89f-5d08-42c6-95dc-7ac16f74e4a6/touch/perform 200 504 ms - 76

My capabilities

        cap.SetCapability(MobileCapabilityType.App, "path");
        cap.SetCapability(MobileCapabilityType.PlatformName, "Android");
        cap.SetCapability(MobileCapabilityType.DeviceName, "device");
        cap.SetCapability(AndroidMobileCapabilityType.AppPackage, PackageName);
        cap.SetCapability(AndroidMobileCapabilityType.NoSign, true);
        cap.SetCapability(MobileCapabilityType.AutomationName, "Appium");
        cap.SetCapability(AndroidMobileCapabilityType.AppWaitActivity, "name.*");
        cap.SetCapability(MobileCapabilityType.NewCommandTimeout, "360");
        cap.SetCapability(AndroidMobileCapabilityType.UnicodeKeyboard, "true");
        cap.SetCapability(AndroidMobileCapabilityType.ResetKeyboard, "true");
        cap.SetCapability("autoGrantPermissions", "true");

#2

can you run the test with cap.SetCapability(MobileCapabilityType.AutomationName, “UIAutomator2”);


#3

Thanks for reply!
Unfortunately situation is exactly the same - in logs everythings looks fine but screen just not move

[HTTP] --> POST /wd/hub/session/1180056b-e369-408a-af8e-3e57a0a47017/touch/perform
[HTTP] {“actions”:[{“action”:“press”,“options”:{“element”:“0bc3fa90-8391-4af2-884b-185903098226”,“x”:324,“y”:1332}},{“action”:“wait”,“options”:{“ms”:500}},{“action”:“moveTo”,“options”:{“element”:“0bc3fa90-8391-4af2-884b-185903098226”,“x”:324,“y”:976}},{“action”:“release”}]}
[debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{“action”:“press”,“options”:{“element”:“0bc3fa90-8391-4af2-884b-185903098226”,“x”:324,“y”:1332}},{“action”:“wait”,“options”:{“ms”:500}},{“action”:“moveTo”,“options”:{“element”:“0bc3fa90-8391-4af2-884b-185903098226”,“x”:324,“y”:976}},{“action”:“release”}],“1180056b-e369-408a-af8e-3e57a0a47017”]
[UiAutomator2] calling get location: 0bc3fa90-8391-4af2-884b-185903098226
[debug] [JSONWP Proxy] Matched ‘/element/0bc3fa90-8391-4af2-884b-185903098226/location’ to command name ‘getLocation’
[debug] [JSONWP Proxy] Proxying [GET /element/0bc3fa90-8391-4af2-884b-185903098226/location] to [GET http://localhost:8200/wd/hub/session/67c86dc2-fa43-4dec-9b5a-96ed39c1f636/element/0bc3fa90-8391-4af2-884b-185903098226/location] with body: {}
[debug] [JSONWP Proxy] Got response with status 200: “{“sessionId”:“67c86dc2-fa43-4dec-9b5a-96ed39c1f636”,“status”:0,“value”:{“x”:0,“y”:585}}”
[debug] [JSONWP Proxy] Matched ‘/element/0bc3fa90-8391-4af2-884b-185903098226/size’ to command name ‘getSize’
[debug] [JSONWP Proxy] Proxying [GET /element/0bc3fa90-8391-4af2-884b-185903098226/size] to [GET http://localhost:8200/wd/hub/session/67c86dc2-fa43-4dec-9b5a-96ed39c1f636/element/0bc3fa90-8391-4af2-884b-185903098226/size] with body: {}
[debug] [JSONWP Proxy] Got response with status 200: “{“sessionId”:“67c86dc2-fa43-4dec-9b5a-96ed39c1f636”,“status”:0,“value”:{“width”:1080,“height”:1007}}”
[UiAutomator2] calling get location: 0bc3fa90-8391-4af2-884b-185903098226
[debug] [JSONWP Proxy] Matched ‘/element/0bc3fa90-8391-4af2-884b-185903098226/location’ to command name ‘getLocation’
[debug] [JSONWP Proxy] Proxying [GET /element/0bc3fa90-8391-4af2-884b-185903098226/location] to [GET http://localhost:8200/wd/hub/session/67c86dc2-fa43-4dec-9b5a-96ed39c1f636/element/0bc3fa90-8391-4af2-884b-185903098226/location] with body: {}
[debug] [JSONWP Proxy] Got response with status 200: “{“sessionId”:“67c86dc2-fa43-4dec-9b5a-96ed39c1f636”,“status”:0,“value”:{“x”:0,“y”:585}}”
[debug] [JSONWP Proxy] Matched ‘/touch/perform’ to command name ‘performTouch’
[debug] [JSONWP Proxy] Proxying [POST /touch/perform] to [POST http://localhost:8200/wd/hub/session/67c86dc2-fa43-4dec-9b5a-96ed39c1f636/touch/perform] with body: {“startX”:324,“startY”:1332,“endX”:324,“endY”:976,“steps”:14,“elementId”:“0bc3fa90-8391-4af2-884b-185903098226”}
[debug] [JSONWP Proxy] Got response with status 200: {“sessionId”:“67c86dc2-fa43-4dec-9b5a-96ed39c1f636”,“status”:0,“value”:true}
[debug] [MJSONWP] Responding to client with driver.performTouch() result: true
[HTTP] <-- POST /wd/hub/session/1180056b-e369-408a-af8e-3e57a0a47017/touch/perform 200 1159 ms - 76
[HTTP]


#4

Try to provide absolute coordinates instead of relative. There is a known bug, which prevents relative elemnt coordinates from being calculated properly


#5

Thanks for reply, it doesn’t help either. Log’s are the same.


#6

The log should not be the same after the element option is removed


#7

@mykola-mokhnach Hi.

Can you help me with the consultation about scrolling with appium version 1.9.1. please.

Environment:
robotframework-appiumlibrary==1.4.6
Appium-Python-Client==0.28
iOS 12
Real Device
Xcode = 10.0
Appium 1.9.1

The issue is not working scroll. In the appium logs I see the response 200 but on the device, nothing happens.
Works only swipe by the coordinates, but it`s not good.

See logs: https://gist.github.com/WaFeIS7/65e49dd4c613adb432214c725bf2bc3a

If I use appium 1.7.2 for the iOS 11.4, real device, the scroll is working.

if any solutions to scroll with the appium 1.9.1 and iOS 12 real device?

Thanks.


#8

Hi Wafe_is_7,
Could you able to send or explain how scroll working for you (If I use appium 1.7.2 for the iOS 11.4, real device, the scroll is working).
I am using appium 1.9.1 for IOS 11.4 real device not working for me.

Thanks


#9

Hello, @sandysandy7
ENV:
Appium 1.7.2
iOS 11.4
Appium-Python-Client==0.28
robotframework-appiumlibrary==1.4.6
Xcode = 9.4.1
This Function inside robotframework-appiumlibrary works correctly

    """
    def scroll(self, start_locator, end_locator):
    Scrolls from one element to another
    Key attributes for arbitrary elements are `id` and `name`. See
    `introduction` for details about locating elements.
    """
    el1 = self._element_find(start_locator, True, True)
    el2 = self._element_find(end_locator, True, True)
    driver = self._current_application()
    driver.scroll(el1, el2)  

In case if I use:
ENV:
Appium 1.9.1
iOS 12 or 11.4
Appium-Python-Client==0.28
robotframework-appiumlibrary==1.4.6
Xcode = 10

That function scroll doesn’t work as expected, in server appium I see response status of the request 200, but nothing happens on the device.
That`s why I want to find any solution to fix it.
And Asked this problem to @mykola-mokhnach


#10

#11

Sorry, I didn’t get that I should delete element :wink: Thanks! It’s working now.
Do you know if that bug will be fixed?


#12

There is a pending PR with the fix, however other maintainers don’t really like the design of it:

Feel free to improve it


#13

Can you please share the code that is working .
Thanks in advance.


#14

Sure. :slight_smile:

private static void Move(this AppiumDriver<IWebElement> driver, Point startMove, Point endMove)
        {
            var action = new TouchAction(driver)
                    .Press(startMove.X, startMove.Y)
                    .Wait(500)
                    .MoveTo(endMove.X, endMove.Y)
                    .Release();

            action.Perform();
  }