-
-
Notifications
You must be signed in to change notification settings - Fork 768
Description
Description
I was trying to write a method to swipe screen(Up/Down) using TouchAction. But while debugging I found that, it throws an error every time the control comes to touchAction methods.
Environment
- java client - 6.1.0(Tried all the version from 6.0.0-BETA1 till 7.0.0 )
- Appium Desktop - 1.8.0
- Desktop OS - MacOS - 10.14.5
- Node.js version - 6.9.0
- Mobile platform/version under test: Android Emulator(Pixel 3,API 26/27)
- Real device or emulator/simulator: Android Emulator
Desired Capabilities
lAPK = PropertiesFileUtils.getdataFromConfig("apk");
capabilities.setCapability("deviceName", lDeviceName);
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", "*********");
capabilities.setCapability("appActivity", "Main");
capabilities.setCapability("autoGrantPermission","true");
capabilities.setCapability("dontStopAppOnReset", "true");
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "60");
Code To Reproduce Issue
//Generic function for Scroll
public static String scrollUsingTouchActions_ByElements(WebElement elementToBeFound, String directionOfScroll, int count) {
TouchAction actions = new TouchAction(_appDriver);
Dimension dimensions = _appDriver.manage().window().getSize();
Double screenHeightStart = 0.0;
int scrollStart = 0;
Double screenHeightEnd = 0.0;
int scrollEnd = 0;
try {
if(directionOfScroll.equalsIgnoreCase("Up")) {
screenHeightStart = dimensions.getHeight() * 0.5;
scrollStart = screenHeightStart.intValue();
screenHeightEnd = dimensions.getHeight() * 0.2;
scrollEnd = screenHeightEnd.intValue();
}else {
screenHeightStart = dimensions.getHeight() * 0.5;
scrollStart = screenHeightStart.intValue();
screenHeightEnd = dimensions.getHeight() * 0.8;
scrollEnd = screenHeightEnd.intValue();
}
while(count > 0) {
try {
actions.press(PointOption.point(500, scrollStart))
.waitAction(WaitOptions.waitOptions(Duration.ofSeconds(2)))
.moveTo(PointOption.point(500, scrollEnd)).release().perform();
if(elementToBeFound.isDisplayed()) {
break;
}
}catch(Exception e) {
e.printStackTrace();
}
count--;
}
return "PASS "+"scrolled successfully";
}catch(Exception e) {
e.printStackTrace();
return "FAIL "+"unable to scroll till the element";
}
}
Ecxeption stacktraces
While debugging I found that, from action method it directly goes to the below method in java.lang.reflect.InvocationTargetException class-
public InvocationTargetException(Throwable target) {
super((Throwable)null); // Disallow initCause
this.target = target;
}
So, no error gets printed in the catch block for action methods.
But here is what gets printed in my console -
https://gist.github.com/pranayasahoo/f952a4cd6e0eb2712a1c4eb82c9321b1
Link to Appium logs
https://gist.github.com/pranayasahoo/2db63718c866ff7432ae67f99b214b50