question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

android and ios treat touchaction coordinates differently (relative vs absolute)

See original GitHub issue

The 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();

server logs

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

image

server log

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jlippscommented, Dec 9, 2016

android and ios should definitely follow the same semantics.

1reaction
TikhomirovSergeycommented, Nov 10, 2017

UPD: The swipe is not supported now. So the problem is moveTo. It seems that it it should accept absolute coordinates for all supported platfoms.

ping @mykola-mokhnach

Read more comments on GitHub >

github_iconTop Results From Across the Web

Touch Actions - Appium
Passing both coordinates and an element will treat the coordinates as relative to the element's position, rather than absolute.
Read more >
Appium::TouchAction.new.tap doesn't work correctly
Given the next code, I work with Appium 1.9.1, Ruby 2.3.7 and Cucumber to automate iOS app, if I'm passing relative coordinates (percentage) ......
Read more >
Chapter-11: Automating gestures - Kobiton
NOTE: This method works in a similar way on Android and iOS but the location differs according to Mobile device being used (given...
Read more >
min-height - CSS: Cascading Style Sheets - MDN Web Docs
Defines the min-height as an absolute value. <percentage>. Defines the min-height as a percentage of the containing block's height. auto.
Read more >
iOS-Specific Touch Action Methods - HeadSpin
element: an element ID, which if provided will cause Appium to treat the coordinates as relative to this element. Absolute screen coordinates ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found