Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference behaviour between iOS and Android regarding with `swipe` action #7702

Closed
KazuCocoa opened this issue Jan 16, 2017 · 7 comments

Comments

Projects
None yet
7 participants
@KazuCocoa
Copy link
Member

commented Jan 16, 2017

The problem

I've investigated about swipe behaviour on appium/ruby_lib#461 .
Then I found the difference behaviour between iOS(ios-driver, xcuitest-driver) and Android(android-driver).
So, this issue is a suggestion to support interface offset_* or end_* ,or support both interfaces.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.6.3
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: Mac OS X 10.12.2
  • Node.js version (unless using Appium.app|exe): v6.0.0
  • Mobile platform/version under test: iOS10.2, 9.3 and Android OS6.0
  • Real device or emulator/simulator: simulator for iOS and realdevice for Android
  • Appium CLI or Appium.app|exe: CLI
  • ruby_lib9.2.0

Details

from appium/ruby_lib#461 (comment)
(You can read more details(driver's code level) in the issue.)

I checked swipe's logs for Android and iOS. Then I found the difference between them.

For Android, the following command's offset_* works as end_*.
For iOS, the following command's offset_* works as offset_*.

swipe(start_x: start_x, start_y: start_y, offset_x: start_y, offset_y: offset_y)

command and logs on Appium1.6.3

Android

  • command
    • pry(#<device/touch_actions>)> swipe start_x: 600, start_y: 919, offset_x: 600, offset_y: 919 - 100
  • results
    • # [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Swiping from [x=600.0, y=919.0] to [x=600.0, y=819.0] with steps: 6
# Example for Android's log
[0] pry(#<device/touch_actions>)> swipe start_x: 600, start_y: 919, offset_x: 600, offset_y: 919 - 100
[HTTP] --> POST /wd/hub/session/9baa18bf-a19b-4654-be4a-d0db0334bbc0/touch/perform {"actions":[{"action":"press","options":{"x":600,"y":919}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":600,"y":819}},{"action":"release"}]}
[debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"x":600,"y":919}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":600,"y":819}},{"action":"release"}],"9baa18bf-a19b-4654-be4a-d0db0334bbc0"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"swipe","params":{"startX":600,"startY":919,"endX":600,"endY":819,"steps":6}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"swipe","params":{"startX":600,"startY":919,"endX":600,"endY":819,"steps":6}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: swipe
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Display bounds: [0,0][1200,1838]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Display bounds: [0,0][1200,1838]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Swiping from [x=600.0, y=919.0] to [x=600.0, y=819.0] with steps: 6
[debug] [AndroidBootstrap] Received command result from bootstrap

iOS

  • command
    • xcuitest: pry(#<device/touch_actions>)> swipe start_x: 187, start_y: 201, offset_x: 0, offset_y: - 50
    • instruments: swipe start_x: 187, start_y: 201, offset_x: 0, offset_y: - 50, duration: 1000
  • results
    • xcuitest
      • [debug] [JSONWP Proxy] Proxying [POST /uiaTarget/0/dragfromtoforduration] to [POST http://localhost:8100/session/0D2991FB-A997-4D6C-94FC-D65CC252EC4B/uiaTarget/0/dragfromtoforduration] with body: {"fromX":187,"fromY":201,"toX":187,"toY":151,"duration":0.2}
    • instruments
      • [debug] [Instruments] [INST] 2017-01-14 08:22:57 +0000 Debug: target.dragFromToForDuration({x:"187", y:"201.078125"}, {x:"187", y:"151.078125"}, "1")
# Example for iOS's log with XCUITest
[0] pry(#<device/touch_actions>)> swipe start_x: start_x, start_y: start_y, offset_x: 0, offset_y: - 50
[debug] [WebDriverAgent] Sim: Jan 14 16:35:05 rrcs-172-254-99-35 CoreSimulatorBridge[65868]: KEYMAP: Chose mode=en_US@hw=Automatic;sw=QWERTY from match=en_US@hw=Automatic;sw=QWERTY from language=en
[HTTP] --> POST /wd/hub/session/cd65fa75-cbd7-4348-a7d6-60cbde28db47/touch/perform {"actions":[{"action":"press","options":{"x":187,"y":201}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":0,"y":-50}},{"action":"release"}]}
[debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"x":187,"y":201}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":0,"y":-50}},{"action":"release"}],"cd65fa75-cbd7-4348-a7d6-60cbde28db47"]
[debug] [XCUITest] Executing command 'performTouch'
[debug] [XCUITest] Received the following touch action: press-wait-moveTo-release
[debug] [JSONWP Proxy] Proxying [POST /uiaTarget/0/dragfromtoforduration] to [POST http://localhost:8100/session/0D2991FB-A997-4D6C-94FC-D65CC252EC4B/uiaTarget/0/dragfromtoforduration] with body: {"fromX":187,"fromY":201,"toX":187,"toY":151,"duration":0.2}
[debug] [WebDriverAgent] Sim: Jan 14 16:35:05 rrcs-172-254-99-35 CoreSimulatorBridge[65868]: Switching to keyboard: en
# Example for iOS's log with Instruments
[0] pry(#<device/touch_actions>)> swipe start_x: start_x, start_y: start_y, offset_x: 0, offset_y: - 50, duration: 1000
[HTTP] <-- POST /wd/hub/session/8b651f03-0fbc-43f0-aaf2-243d0650f6aa/touch/perform 200 2048 ms - 74
[HTTP] --> POST /wd/hub/session/8b651f03-0fbc-43f0-aaf2-243d0650f6aa/touch/perform {"actions":[{"action":"press","options":{"x":187,"y":201.078125}},{"action":"wait","options":{"ms":1000}},{"action":"moveTo","options":{"x":0,"y":-50}},{"action":"release"}]}
[debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"x":187,"y":201.078125}},{"action":"wait","options":{"ms":1000}},{"action":"moveTo","options":{"x":0,"y":-50}},{"action":"release"}],"8b651f03-0fbc-43f0-aaf2-243d0650f6aa"]
[debug] [iOS] Executing iOS command 'performTouch'
[debug] [UIAuto] Sending command to instruments: au.dragApp(187, 201.078125, 187, 151.078125, 1)
[debug] [Instruments] [INST] 2017-01-14 08:22:57 +0000 Debug: Got new command 12 from instruments: au.dragApp(187, 201.078125, 187, 151.078125, 1)
[debug] [Instruments] [INST] 2017-01-14 08:22:57 +0000 Debug: evaluating au.dragApp(187, 201.078125, 187, 151.078125, 1)
[debug] [Instruments] [INST] 2017-01-14 08:22:57 +0000 Debug: target.dragFromToForDuration({x:"187", y:"201.078125"}, {x:"187", y:"151.078125"}, "1")
[debug] [Instruments] [INST] 2017-01-14 08:22:58 +0000 Debug: evaluation finished
[debug] [Instruments] [INST] 2017-01-14 08:22:58 +0000 Debug: responding with:
[debug] [UIAuto] Socket data received (25 bytes)
[debug] [UIAuto] Got result from instruments: {"status":0,"value":""}
[debug] [MJSONWP] Responding to client with driver.performTouch() result: ""
[HTTP] <-- POST /wd/hub/session/8b651f03-0fbc-43f0-aaf2-243d0650f6aa/touch/perform 200 1895 ms - 74

Link to Appium logs

Attached the above.

Expected(Suggestion)

case1: support only end_* for iOS and Android

  • command
swipe start_x: 600, start_y: 919, end_x: 600, end_y: 919 - 100
  • behaviour for android and ios
# [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Swiping from [x=600.0, y=919.0] to [x=600.0, y=819.0] with steps: 6
[debug] [JSONWP Proxy] Proxying [POST /uiaTarget/0/dragfromtoforduration] to [POST http://localhost:8100/session/0D2991FB-A997-4D6C-94FC-D65CC252EC4B/uiaTarget/0/dragfromtoforduration] with body: {"fromX":600.0,"fromY":919.0,"toX":600.0,"toY":819.0,"duration":0.2}

case2: support only offset_* for iOS and Android

  • command
swipe start_x: 600, start_y: 919, offset_x: 0, offset_y: - 100
  • behaviour for android and ios
# [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Swiping from [x=600.0, y=919.0] to [x=600.0, y=819.0] with steps: 6
[debug] [JSONWP Proxy] Proxying [POST /uiaTarget/0/dragfromtoforduration] to [POST http://localhost:8100/session/0D2991FB-A997-4D6C-94FC-D65CC252EC4B/uiaTarget/0/dragfromtoforduration] with body: {"fromX":600.0,"fromY":919.0,"toX":600.0,"toY":819.0,"duration":0.2}

case3: support offset_* and end_* for iOS and Android

  • command

    • swipe start_x: 600, start_y: 919, end_x: 600, end_y: 919 - 100
      • Then Appium driver works as end point. (Both iOS and Android)
  • command

    • swipe start_x: 600, start_y: 919, offset_x: 0, offset_y: - 100
      • Then Appium server works as offset. (Both iOS and Android)
@jlipps

This comment has been minimized.

Copy link
Member

commented Jan 16, 2017

Thanks for investigating this @KazuCocoa. We should not have any discrepancies between the platforms. It seems to me that the server should deal in absolute values, and if clients want to deal in offsets, they are free to provide the ability to do so. @imurchie do you agree? I tried to read the current webdriver spec for guidance but it has diverged so much from the implementation of TouchAction we use it was hard to follow.

@jwang-net

This comment has been minimized.

Copy link

commented Jan 25, 2017

This is also the case with the python library. There was apparently a point in time (during 1.4) where the TouchAction for iOS used absolute values. After 1.5, swipe for IOS has been taking relative values for end_x and end_y... not sure if this is the intended behavior or not.

#6257 (comment)

@jlipps

This comment has been minimized.

Copy link
Member

commented Jan 25, 2017

Thanks @jwang-net. Still looking for some guidance from @imurchie. Adding to our backlog in the meantime if only as an investigation

@KazuCocoa

This comment has been minimized.

Copy link
Member Author

commented Mar 3, 2017

appium/python-client#155 is related to this issue, I think.

@dpgraham dpgraham added the P1 label Jul 17, 2017

@chenxiancai

This comment has been minimized.

Copy link

commented Aug 29, 2017

This issue happen to me.In xcuitest swipe is (start_x: 187, start_y: 201, offset_x: 0, offset_y: 50,duration:500).In uiautomator2 swipe is (start_x: 187, start_y: 201, end_x: 0, end_y: 50,duration:500)

@KazuCocoa

This comment has been minimized.

Copy link
Member Author

commented Feb 15, 2018

moveTo was absolute based value for both Android and iOS from Appium 1.8.0.
I've removed some calculation for relative/absolute in ruby_lib.
https://github.com/appium/ruby_lib/blob/master/CHANGELOG.md#v9100

We don't need to change the python client since the client sends it to the server without any calculations in client side.

@lock

This comment has been minimized.

Copy link

commented Apr 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Apr 24, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.