android and ios treat touchaction coordinates differently (relative vs absolute)
See original GitHub issueThe problem
The problem is that the swiping on Android still consumes absolute values instead of relative (like iOS).
However the moveTo
action consumes relative values on both Android and iOS. So it makes inconvenience on client side.
Also there is some weird behaviour. When user tries to perform the swiping twise (may be more times) per one TouchAction then it fails with error that says that point is out of screen.
Environment
- Appium version 1.6.0, 1.6.1 and older:
- Desktop OS/version used to run Appium: I was trying it on Windows 7/8
- Node.js version (unless using Appium.app|exe): doesn’t matter
- Mobile platform/version under test: Android
- Real device or emulator/simulator: Emulator
Details
I think the solution is to make the swiping accept relative coordinate values or to stop support it.
Link to Appium logs
Create a gist which is a paste of your full Appium logs, and link them here. Do not paste your full Appium logs here, as it will make this issue very long and hard to read! If you are reporting a bug, always include Appium logs!
Code To Reproduce Issue [ Good To Have ]
The client code
driver.findElementByAccessibilityId("Views").click();
AndroidElement chronometer = driver.findElementByAccessibilityId("Chronometer");
Point point1 = chronometer.getCenter();
int x1 = point1.getX();
int y1 = point1.getY();
AndroidElement focus = driver.findElementByAccessibilityId("Focus");
Point point2 = focus.getCenter();
int x2 = point2.getX();
int y2 = point2.getY();
TouchAction touchAction = new TouchAction(driver);
touchAction.press(x2, y2).waitAction(2000).moveTo(x1, y1).release()//swipe 1
.press(x1, y1).waitAction(2000).moveTo(x2, y2).release() //swipe 2, seems it needs for relative values
.perform();
However this code works
driver.findElementByAccessibilityId("Views").click();
AndroidElement chronometer = driver.findElementByAccessibilityId("Chronometer");
Point point1 = chronometer.getCenter();
int x1 = point1.getX();
int y1 = point1.getY();
AndroidElement focus = driver.findElementByAccessibilityId("Focus");
Point point2 = focus.getCenter();
int x2 = point2.getX();
int y2 = point2.getY();
TouchAction touchAction1 = new TouchAction(driver);
touchAction1.press(x2, y2).waitAction(2000).moveTo(x1, y1).release().perform();
TouchAction touchAction2 = new TouchAction(driver);
touchAction2.press(x1, y1).waitAction(2000).moveTo(x2, y2).release()
.perform();
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:7 (4 by maintainers)
Top GitHub Comments
android and ios should definitely follow the same semantics.
UPD: The
swipe
is not supported now. So the problem ismoveTo
. It seems that it it should accept absolute coordinates for all supported platfoms.ping @mykola-mokhnach