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");