appium-espresso-driver icon indicating copy to clipboard operation
appium-espresso-driver copied to clipboard

Swipe not performed if startPoint is over an element.

Open liviudanu-ellation opened this issue 6 years ago • 15 comments

Hi. There is a issue when I try to perform a swipe. If the start point of the swipe is over an element swipe is not performed; If the start point is over an empty space everything works fine

Appium version: 1.11.0-rc.0 Java-client version: 7.0.0 Espresso driver version: 1.6.0

Below are two recordings of the issue with appium desktop 1.10.0 server version.

SwipeRecording.zip

Appium server log: https://gist.github.com/liviudanu-ellation/675f541b761108f0a8c8dd92c5fed73c Java code snippet : https://gist.github.com/liviudanu-ellation/6ddf07e8c18e4b029b510c1aaf20d510

If I missed some important details, please let me know

liviudanu-ellation avatar Jan 09 '19 12:01 liviudanu-ellation

Please attach the server logs and the client code snippets

mykola-mokhnach avatar Jan 09 '19 18:01 mykola-mokhnach

@mykola-mokhnach I've updated the issue description.

liviudanu-ellation avatar Jan 10 '19 13:01 liviudanu-ellation

wait action duration is unset

mykola-mokhnach avatar Jan 10 '19 18:01 mykola-mokhnach

Unfortunately, setting waitOptions does not make any difference, swipe is still not performed. Please note that the issue only happens when using Espresso as automation name, for uiautomator2 everything works fine.

liviudanu-ellation avatar Jan 11 '19 15:01 liviudanu-ellation

Having the same issue. Can't get the swiping to work.

Here is the code used in tests:

            new TouchAction(driver)
                    .press(PointOption.point(startX, startY))
                    .waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000)))
                    .moveTo(PointOption.point(endX, endY))
                    .release()
                    .perform();

it works with UIAutomator2

Also, the swipe doesn't work on Appium Desktop 12.1 using Swipe By Coordinates by just clicking start-point and then end-point on the screen. By enabling Point Location from Developer Options (to see the pointer's passed path on the screen) it is visible that start-point is clicked then the pointer is moved to end-point then released, but the page doesn't move, while swipe works manually.

I am using Appium v1.12.1 EspressoDriver (v1.10.0) It is tested and doesn't work also on Appium 1.13.0-beta.3

Here is the log portion of Appium Desktop's Swipe By Coordinates

[info] [HTTP] [info] [HTTP] --> GET /wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5
[info] [HTTP] {}
[debug] [MJSONWP (4c55442e)] Calling AppiumDriver.getSession() with args: ["4c55442e-d29a-4273-8275-48d8ae97c3e5"]
[debug] [MJSONWP (4c55442e)] Responding to client with driver.getSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"build.apk","appActivity":"com.project.project.android.MainActivity","appPackage":"com.project.project.android","automationName":"Espresso","deviceName":"emulator","keyAlias":"keyAlias","keyPassword":"keyPassword","keystorePassword":"keystorePassword","keystorePath":"path\\debug.keystore","newCommandTimeout":100000,"platformName":"Android","udid":"emulator-5556","connectHardwareKeyboard":true},"app":"build.apk","appActivity":"com.project.project.android.MainActivity","appPackage":"com.project.project.android","automationName":"Espresso","deviceName":"emulator-5556","ignoreUnimp...
[info] [HTTP] <-- GET /wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5 200 2 ms - 1581
[info] [HTTP] [info] [HTTP] --> POST /wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5/touch/perform
[info] [HTTP] {"actions":[{"action":"press","options":{"x":808,"y":1115}},{"action":"moveTo","options":{"x":808,"y":575}},{"action":"release","options":{}}]}
[info] [MJSONWP (4c55442e)] Driver proxy active, passing request on via HTTP proxy
[debug] [WD Proxy] Matched '/wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5/touch/perform' to command name 'performTouch'
[debug] [WD Proxy] Proxying [POST /wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5/touch/perform] to [POST http://localhost:8300/session/b2923c7c-5e74-42c1-849b-0fe2e2f3b575/touch/perform] with body: {"actions":[{"action":"press","options":{"x":808,"y":1115}},{"action":"moveTo","options":{"x":808,"y":575}},{"action":"release","options":{}}]}[debug] [WD Proxy] Got response with status 200: {"id":"f97fd92d-1582-41c7-b4a6-56199520d550","sessionId":"b2923c7c-5e74-42c1-849b-0fe2e2f3b575","status":0,"value":null}
[info] [WD Proxy] Replacing sessionId b2923c7c-5e74-42c1-849b-0fe2e2f3b575 with 4c55442e-d29a-4273-8275-48d8ae97c3e5
[info] [HTTP] <-- POST /wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5/touch/perform 200 414 ms - 120
[info] [HTTP] [info] [HTTP] --> GET /wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5/source
[info] [HTTP] {}
[info] [MJSONWP (4c55442e)] Driver proxy active, passing request on via HTTP proxy
[info] [HTTP] --> GET /wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5/screenshot
[info] [HTTP] {}
[info] [MJSONWP (4c55442e)] Driver proxy active, passing request on via HTTP proxy
[debug] [WD Proxy] Matched '/wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5/source' to command name 'getPageSource'
[debug] [WD Proxy] Proxying [GET /wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5/source] to [GET http://localhost:8300/session/b2923c7c-5e74-42c1-849b-0fe2e2f3b575/source] with body: {}
[info] [HTTP] --> GET /wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5/window/current/size
[info] [HTTP] {}
[info] [MJSONWP (4c55442e)] Driver proxy active, passing request on via HTTP proxy[info] [HTTP] --> GET /wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5
[info] [HTTP] {}
[debug] [MJSONWP (4c55442e)] Calling AppiumDriver.getSession() with args: ["4c55442e-d29a-4273-8275-48d8ae97c3e5"][debug] [WD Proxy] Got response with status 200: "{\"id\":\"0960d886-ca48-4d9b-be57-921a9e25bfed\",\"sessionId\":\"b2923c7c-5e74-42c1-849b-0fe2e2f3b575\",\"status\":0,\"value\":\"\\u003c?xml version\\u003d\\u00271.0\\u0027 encoding\\u003d\\u0027UTF-8\\u0027 standalone\\u003d\\u0027yes\\u0027 ?\\u003e\\u003ccom.android.internal.policy.DecorView index\\u003d\\\"0\\\" package\\u003d\\\"com.project.project.android\\\" class\\u003d\\\"com.android.internal.policy.DecorView\\\" checkable\\u003d\\\"false\\\" checked\\u003d\\\"false\\\" clickable\\u003d\\\"false\\\" enabled\\u003d\\\"true\\\" focusable\\u003d\\\"false\\\" focused\\u003d\\\"false\\\" scrollable\\u003d\\\"false\\\" long-clickable\\u003d\\\"false\\\" password\\u003d\\\"false\\\" selected\\u003d\\\"false\\\" visible\\u003d\\\"true\\\" bounds\\u003d\\\"[0,0][1080,1920]\\\" viewIndex\\u003d\\\"0\\\"\\u003e  \\u003candroid.widget.LinearLayout index\\u003d\\\"0\\\" package\\u003d\\\"com.project.project.android\\\" class\\u003d\\\"android.widget.LinearLayout\\\" checkable\\u003d\\\"fal...
[info] [WD Proxy] Replacing sessionId b2923c7c-5e74-42c1-849b-0fe2e2f3b575 with 4c55442e-d29a-4273-8275-48d8ae97c3e5
[info] [HTTP] <-- GET /wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5/source 200 747 ms - 242794
[info] [HTTP] 
[debug] [WD Proxy] Matched '/wd/hub/session/4c55442e-d29a-4273-8275-48d8ae97c3e5/screenshot' to command name 'getScreenshot'

uterator avatar May 09 '19 00:05 uterator

[info] [HTTP] {"actions":[{"action":"press","options":{"x":808,"y":1115}},{"action":"moveTo","options":{"x":808,"y":575}},{"action":"release","options":{}}]}

I don't observe the wait after press in this command

mykola-mokhnach avatar May 09 '19 05:05 mykola-mokhnach

Hi @mykola-mokhnach, thank you for your quick response, it was an Appium Desktop log, seems it's missing the wait after press, please let me know if I need to report that separately.

I have run the test with this command but swipe didn't work again

            new TouchAction(driver)
                    .press(PointOption.point(startX, startY))
                    .waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000)))
                    .moveTo(PointOption.point(endX, endY))
                    .release()
                    .perform();

here are the executed actions

{
    "actions": [
        {
            "action": "press",
            "options": {
                "x": 54,
                "y": 1255
            }
        },
        {
            "action": "wait",
            "options": {
                "ms": 1000
            }
        },
        {
            "action": "moveTo",
            "options": {
                "x": 54,
                "y": 538
            }
        },
        {
            "action": "release",
            "options": {}
        }
    ]
}

and here is the log portion of it:

2019-05-10 16:52:34:995 - [HTTP] <-- GET /wd/hub/session/bc8488b1-eed1-43e1-9894-d1f8e4aaea6e 200 3 ms - 1713
2019-05-10 16:52:34:995 - [HTTP] 
2019-05-10 16:52:35:000 - [HTTP] --> GET /wd/hub/session/bc8488b1-eed1-43e1-9894-d1f8e4aaea6e
2019-05-10 16:52:35:000 - [HTTP] {}
2019-05-10 16:52:35:000 - [debug] [W3C (bc8488b1)] Calling AppiumDriver.getSession() with args: ["bc8488b1-eed1-43e1-9894-d1f8e4aaea6e"]
2019-05-10 16:52:35:001 - [debug] [W3C (bc8488b1)] Responding to client with driver.getSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":true,"warnings":{},"desired":{"platformName":"android","locationContextEnabled":true,"app":"build.apk","appActivity":"-","appPackage":"-","automationName":"Espresso","avd":"api27","avdLaunchTimeout":180000,"avdReadyTimeout":180000,"deviceName":"api27","keyAlias":"-","keyPassword":"-","keystorePassword":"-","keystorePath":"-","newComm
andTimeout":300,"platformVersion":"","udid":"emulator-5554"},"platformName":"android","app":"build.apk","appActivity":"-","appPackage":"-"
2019-05-10 16:52:35:002 - [HTTP] <-- GET /wd/hub/session/bc8488b1-eed1-43e1-9894-d1f8e4aaea6e 200 2 ms - 1713
2019-05-10 16:52:35:002 - [HTTP] 
2019-05-10 16:52:35:008 - [HTTP] --> GET /wd/hub/session/bc8488b1-eed1-43e1-9894-d1f8e4aaea6e/window/rect
2019-05-10 16:52:35:008 - [HTTP] {}
2019-05-10 16:52:35:009 - [W3C (bc8488b1)] Driver proxy active, passing request on via HTTP proxy
2019-05-10 16:52:35:014 - [debug] [WD Proxy] Matched '/wd/hub/session/bc8488b1-eed1-43e1-9894-d1f8e4aaea6e/window/rect' to command name 'getWindowRect'
2019-05-10 16:52:35:014 - [debug] [WD Proxy] Proxying [GET /wd/hub/session/bc8488b1-eed1-43e1-9894-d1f8e4aaea6e/window/rect] to [GET http://localhost:8300/session/30568b56-438a-4a26-9ce8-f6542bba8429/window/rect] with body: {}
2019-05-10 16:52:35:036 - [debug] [WD Proxy] Got response with status 200: "{\"id\":\"f4a2f47b-beab-42ba-8c2b-b7ddb7b80f27\",\"sessionId\":\"30568b56-438a-4a26-9ce8-f6542b16:52:35 [LOG::INFO] swipe x:54->54 y:1255->538
ba8429\",\"status\":0,\"value\":{\"height\":1794,\"width\":1080,\"x\":0,\"y\":0,\"uriParams\":null}}"
2019-05-10 16:52:35:036 - [WD Proxy] Replacing sessionId 30568b56-438a-4a26-9ce8-f6542bba8429 with bc8488b1-eed1-43e1-9894-d1f8e4aaea6e
2019-05-10 16:52:35:036 - [HTTP] <-- GET /wd/hub/session/bc8488b1-eed1-43e1-9894-d1f8e4aaea6e/window/rect 200 28 ms - 173
2019-05-10 16:52:35:037 - [HTTP] 
2019-05-10 16:52:36:049 - [HTTP] --> POST /wd/hub/session/bc8488b1-eed1-43e1-9894-d1f8e4aaea6e/touch/perform
2019-05-10 16:52:36:050 - [HTTP] {"actions":[{"action":"press","options":{"x":54,"y":1255}},{"action":"wait","options":{"ms":1000}},{"action":"moveTo","options":{"x":54,"y":538}},{"action":"release","options":{}}]}
2019-05-10 16:52:36:050 - [W3C (bc8488b1)] Driver proxy active, passing request on via HTTP proxy
2019-05-10 16:52:36:051 - [debug] [WD Proxy] Matched '/wd/hub/session/bc8488b1-eed1-43e1-9894-d1f8e4aaea6e/touch/perform' to command name 'performTouch'
2019-05-10 16:52:36:052 - [debug] [WD Proxy] Proxying [POST /wd/hub/session/bc8488b1-eed1-43e1-9894-d1f8e4aaea6e/touch/perform] to [POST http://localhost:8300/session/30568b56-438a-4a26-9ce8-f6542bba8429/touch/perform] with body: {"actions":[{"action":"press","options":{"x":54,"y":1255}},{"action":"wait","options":{"ms":1000}},{"action":"moveTo","options":{"x":54,"y":538}},{"action":"release","options":{}}]}
2019-05-10 16:52:36:530 - [debug] [WD Proxy] Got response with status 200: {"id":"0b4268b2-a000-4234-a5f7-c1f992b0b08d","sessionId":"30568b56-438a-4a26-9ce8-f6542bba8429","status":0,"value":null}
2019-05-10 16:52:36:530 - [WD Proxy] Replacing sessionId 30568b56-438a-4a26-9ce8-f6542bba8429 with bc8488b1-eed1-43e1-9894-d1f8e4aaea6e
2019-05-10 16:52:36:531 - [HTTP] <-- POST /wd/hub/session/bc8488b1-eed1-43e1-9894-d1f8e4aaea6e/touch/perform 200 480 ms - 120
2019-05-10 16:52:36:531 - [HTTP] 
2019-05-10 16:52:37:033 - [HTTP] --> POST /wd/hub/session/bc8488b1-eed1-43e1-9894-d1f8e4aaea6e/appium/stop_recording_screen
2019-05-10 16:52:37:034 - [HTTP] {}

uterator avatar May 10 '19 13:05 uterator

@mykola-mokhnach, I've compared the TouchAction behavior on both drivers. The wait() has no effect on Espresso driver but works on UIAutomator2.

The following actions had been sent to /wd/hub/session/<session-id>/touch/perform endpoint

{
    "actions": [
        {
            "action": "press",
            "options": {
                "x": 54,
                "y": 1255
            }
        },
        {
            "action": "wait",
            "options": {
                "ms": 1000
            }
        },
        {
            "action": "moveTo",
            "options": {
                "x": 54,
                "y": 538
            }
        },
        {
            "action": "release",
            "options": {}
        }
    ]
}

That swipe's cursor movement happens quickly on Espresso and the screen stay un-swiped. No any wait action's value change does any change on swipe speed. At the same time on the same server but with another session when that actions are performed on UIAutomator2 session, the wait action's value changes are clearly observable.

@mykola-mokhnach please let me know if I can help with testing this issue.

Thanks

uterator avatar May 13 '19 11:05 uterator

Thanks for checking that @uterator I hope @dpgraham would have some time to check the implementation

mykola-mokhnach avatar May 13 '19 12:05 mykola-mokhnach

I'll try to have a look at it this evening.

dpgraham avatar May 14 '19 15:05 dpgraham

Hi @dpgraham, were you able to have a look at this issue?

uterator avatar Jun 02 '19 20:06 uterator

I haven't unfortunately. I'm on holidays right now but will be back in a couple weeks.

dpgraham avatar Jun 05 '19 04:06 dpgraham

Hi @dpgraham, were you able to find a time to check the issue? I hope it will be a quick fix for you. With this issue, it is hard to keep tests stable.

uterator avatar Jul 12 '19 13:07 uterator

It turns out if perform "mutliMoveTo" action, the swipe works (but not perfectly)

{
    "actions": [
        {
            "action": "press",
            "options": {
                "x": 54,
                "y": 1255
            }
        },
        {
            "action": "moveTo",
            "options": {
                "x": 54,
                "y": 1000
            }
        },
        {
            "action": "moveTo",
            "options": {
                "x": 54,
                "y": 800
            }
        },
        {
            "action": "release",
            "options": {}
        }
    ]
}

uterator avatar Nov 04 '19 09:11 uterator

This issue still happens, but the workaround suggested by @uterator works perfectly. Just adding an additional point in the middle of the swipe points fixes the situation.

middleX = startX + ((endX - startX) * 0.5) middleY = startY + ((endY - startY) * 0.5) new TouchAction(driver) .press(PointOption.point(startX, startY)) .waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000))) .moveTo(PointOption.point(middleX, middleY)) .moveTo(PointOption.point(endX, endY)) .release() .perform();

JuanCarlos-Arceredillo avatar Nov 22 '21 10:11 JuanCarlos-Arceredillo