appium / appium-espresso-driver

Espresso integration for Appium
Apache License 2.0
191 stars 75 forks source link

Make 'touch' the default interaction #244

Closed juandg closed 6 years ago

juandg commented 6 years ago

I have a very simple test that scrolls down on a list of elements and works well when I use the UIAutomator2 driver for Android or XCUITest driver for iOS, but it fails as soon as I switch to the Espresso driver.

For what is worth the app is written on React Native so that might have something to do with the issue I'm seeing, but I still think that since it works on the other two drivers (XCUITest and UIAutomator2) this should work on the Espresso driver as well.

I'm using the Python client and this is a simplified version of my code:

top_element = get_element('top-cell')
bottom_element = get_element('bottom-cell')
actions = TouchAction(driver)
(actions.long_press(bottom_element)
         .move_to(top_element)
         .release()

def get_element(element_id):
        element_ready = expected_conditions.presence_of_element_located(
            (MobileBy.ACCESSIBILITY_ID, element_id))
        return self.wait.until(element_ready)

And these are the relevant Appium Server logs. There are no errors on the logs as you can see, but the app simply doesn't scroll.

[JSONWP Proxy] Proxying [POST /wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/element/fdf24285-b9c2-4723-9e62-42d9a311b401/click] to [POST http://localhost:8080/session/0c5eb84a-7ec8-491f-b30f-d7b1d429438d/element/fdf24285-b9c2-4723-9e62-42d9a311b401/click] with body: {"id":"fdf24285-b9c2-4723-9e62-42d9a311b401","sessionId":"b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29"}
[JSONWP Proxy] Got response with status 200: {"id":"f95ef160-e24d-4916-bdeb-893af2139dba","sessionId":"0c5eb84a-7ec8-491f-b30f-d7b1d429438d","status":0,"value":null}
[JSONWP Proxy] Replacing sessionId 0c5eb84a-7ec8-491f-b30f-d7b1d429438d with b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29
[HTTP] <-- POST /wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/element/fdf24285-b9c2-4723-9e62-42d9a311b401/click 200 419 ms - 120
[HTTP] 
[HTTP] --> POST /wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/element
[HTTP] {"using":"accessibility id","value":"top-cell","sessionId":"b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29"}
[W3C] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Matched '/wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/element' to command name 'findElement'
[JSONWP Proxy] Proxying [POST /wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/element] to [POST http://localhost:8080/session/0c5eb84a-7ec8-491f-b30f-d7b1d429438d/element] with body: {"using":"accessibility id","value":"top-cell","sessionId":"b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29"}
[JSONWP Proxy] Got response with status 200: {"id":"62c6e291-5ef1-4543-908c-e301166b3f00","sessionId":"0c5eb84a-7ec8-491f-b30f-d7b1d429438d","status":0,"value":{"ELEMENT":"6be7e18b-e62a-4ec1-8c7c-cb9976845b59"}}
[JSONWP Proxy] Replacing sessionId 0c5eb84a-7ec8-491f-b30f-d7b1d429438d with b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29
[HTTP] <-- POST /wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/element 200 57 ms - 166
[HTTP] 
[HTTP] --> POST /wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/element
[HTTP] {"using":"accessibility id","value":"bottom-cell","sessionId":"b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29"}
[W3C] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Matched '/wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/element' to command name 'findElement'
[JSONWP Proxy] Proxying [POST /wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/element] to [POST http://localhost:8080/session/0c5eb84a-7ec8-491f-b30f-d7b1d429438d/element] with body: {"using":"accessibility id","value":"bottom-cell","sessionId":"b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29"}
[JSONWP Proxy] Got response with status 200: {"id":"49a5d26d-daa1-4fbb-a796-9887aa8b17c7","sessionId":"0c5eb84a-7ec8-491f-b30f-d7b1d429438d","status":0,"value":{"ELEMENT":"51fd0f10-715c-463a-8259-82f32b0ad454"}}
[JSONWP Proxy] Replacing sessionId 0c5eb84a-7ec8-491f-b30f-d7b1d429438d with b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29
[HTTP] <-- POST /wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/element 200 57 ms - 166
[HTTP] 
[HTTP] --> POST /wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/touch/perform
[HTTP] {"actions":[{"action":"longPress","options":{"element":"51fd0f10-715c-463a-8259-82f32b0ad454","duration":1000}},{"action":"moveTo","options":{"element":"6be7e18b-e62a-4ec1-8c7c-cb9976845b59"}},{"action":"release","options":{}}],"sessionId":"b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29"}
[W3C] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Matched '/wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/touch/perform' to command name 'performTouch'
[JSONWP Proxy] Proxying [POST /wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/touch/perform] to [POST http://localhost:8080/session/0c5eb84a-7ec8-491f-b30f-d7b1d429438d/touch/perform] with body: {"actions":[{"action":"longPress","options":{"element":"51fd0f10-715c-463a-8259-82f32b0ad454","duration":1000}},{"action":"moveTo","options":{"element":"6be7e18b-e62a-4ec1-8c7c-cb9976845b59"}},{"action":"release","options":{}}],"sessionId":"b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29"}
[JSONWP Proxy] Got response with status 200: {"id":"40ebf152-76eb-40a9-bf33-36f1a99f87a9","sessionId":"0c5eb84a-7ec8-491f-b30f-d7b1d429438d","status":0,"value":null}
[JSONWP Proxy] Replacing sessionId 0c5eb84a-7ec8-491f-b30f-d7b1d429438d with b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29
[HTTP] <-- POST /wd/hub/session/b8d1d506-c81d-4b1c-b4ee-ff7c1a677b29/touch/perform 200 599 ms - 120
jlipps commented 6 years ago

@juandg please try a W3C action instead of one of the old appium actions

juandg commented 6 years ago

@jlipps: You mean using ActionChains instead of TouchAction? W3C Actions

That doesn't seem to work either. I tried to find an implementation of ActionChains on the Python Client but there doesn't seem to be one, so I had to import it from Selenium:

from selenium.webdriver.common.action_chains import ActionChains

I tried two different actions:

    actions = ActionChains(driver)
    (actions.click_and_hold(bottom_element)
    .move_to_element(top_element)
    .release())
    perform()

and

    actions = ActionChains(driver)
    actions.drag_and_drop(bottom_element, top_element).perform()

But none of them seems to work and worst yet is that now XCUITest doesn't work either. The Java exception thrown by the Espresso driver is "IllegalArgumentException: pointerIndex out of range" which doesn't make sense to me since Appium did find the elements. The error for XCUITest is this one: NSLocalizedDescription=Only actions of 'pointer' type are supported. 'key' is given instead for action with id 'key'

The frustrating thing as I mentioned is that TouchAction works fine with XCUITest and UIAutomator2 drivers.

Here's the full Java exception thrown:

selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at android.support.test.espresso.base.Interrogator.getNextMessage(Interrogator.java:212)
    at android.support.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:152)
    at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:472)
    at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:419)
    at android.support.test.espresso.base.UiControllerImpl.injectMotionEvent(UiControllerImpl.java:240)
    at io.appium.espressoserver.lib.helpers.w3c.adapter.espresso.MotionEventBuilder$MotionEventRunner.run(MotionEventBuilder.java:196)
    at io.appium.espressoserver.lib.helpers.w3c.adapter.espresso.AndroidMotionEvent.pointerEvent(AndroidMotionEvent.java:53)
    at io.appium.espressoserver.lib.helpers.w3c.adapter.espresso.EspressoW3CActionAdapter.pointerUp(EspressoW3CActionAdapter.java:312)
    at io.appium.espressoserver.lib.helpers.w3c.dispatcher.PointerDispatch.dispatchPointerEvent(PointerDispatch.java:72)
    at io.appium.espressoserver.lib.helpers.w3c.dispatcher.PointerDispatch.dispatchPointerUp(PointerDispatch.java:116)
    at io.appium.espressoserver.lib.helpers.w3c.models.ActionObject.dispatch(ActionObject.java:127)
    at io.appium.espressoserver.lib.helpers.w3c.models.Tick.dispatchAll(Tick.java:72)
    at io.appium.espressoserver.lib.helpers.w3c.models.ActionSequence.dispatch(ActionSequence.java:86)
    at io.appium.espressoserver.lib.helpers.w3c.models.Actions.perform(Actions.java:56)
    at io.appium.espressoserver.lib.handlers.PeformActions$1.run(PeformActions.java:21)
    at io.appium.espressoserver.lib.handlers.PeformActions$1.run(PeformActions.java:17)
    at io.appium.espressoserver.lib.viewaction.UiControllerPerformer.perform(UiControllerPerformer.java:43)
    at android.support.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:356)
    at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:241)
    at android.support.test.espresso.ViewInteraction.access$100(ViewInteraction.java:62)
    at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:149)
    at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:146)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at android.support.test.espresso.base.Interrogator.getNextMessage(Interrogator.java:206)
    ... 29 more
Caused by: java.lang.IllegalArgumentException: pointerIndex out of range
    at android.view.MotionEvent.nativeGetAxisValue(Native Method)
    at android.view.MotionEvent.getY(MotionEvent.java:2216)
    at android.widget.ScrollView.onSecondaryPointerUp(ScrollView.java:780)
    at android.widget.ScrollView.onInterceptTouchEvent(ScrollView.java:600)
    at com.facebook.react.views.scroll.ReactScrollView.onInterceptTouchEvent(ReactScrollView.java:183)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2504)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2983)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:445)
    at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1828)
    at android.app.Activity.dispatchTouchEvent(Activity.java:3292)
    at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:407)
    at android.view.View.dispatchPointerEvent(View.java:11964)
    at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4776)
    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4590)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4274)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4331)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
    at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6642)
    at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6616)
    at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6577)
    at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6745)
    at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:325)
    ... 31 more

And here's the Appium log minus the Java exception that's above:

[HTTP] --> POST /wd/hub/session/bcf5d143-7904-4d9f-8bbb-4d8dc54ec340/element
[HTTP] {"using":"accessibility id","value":"top-cell","sessionId":"bcf5d143-7904-4d9f-8bbb-4d8dc54ec340"}
[W3C] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Matched '/wd/hub/session/bcf5d143-7904-4d9f-8bbb-4d8dc54ec340/element' to command name 'findElement'
[JSONWP Proxy] Proxying [POST /wd/hub/session/bcf5d143-7904-4d9f-8bbb-4d8dc54ec340/element] to [POST http://localhost:8080/session/b88ea738-62a5-4ca2-b324-c837c9de2ee8/element] with body: {"using":"accessibility id","value":"top-cell","sessionId":"bcf5d143-7904-4d9f-8bbb-4d8dc54ec340"}
[JSONWP Proxy] Got response with status 200: {"id":"ac3c87a4-37f0-4659-8570-94e1c0681001","sessionId":"b88ea738-62a5-4ca2-b324-c837c9de2ee8","status":0,"value":{"ELEMENT":"46d452f2-7f27-4aa4-849c-e1418b125b03"}}
[JSONWP Proxy] Replacing sessionId b88ea738-62a5-4ca2-b324-c837c9de2ee8 with bcf5d143-7904-4d9f-8bbb-4d8dc54ec340
[HTTP] <-- POST /wd/hub/session/bcf5d143-7904-4d9f-8bbb-4d8dc54ec340/element 200 98 ms - 166
[HTTP] 
[HTTP] --> POST /wd/hub/session/bcf5d143-7904-4d9f-8bbb-4d8dc54ec340/element
[HTTP] {"using":"accessibility id","value":"bottom-cell","sessionId":"bcf5d143-7904-4d9f-8bbb-4d8dc54ec340"}
[W3C] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Matched '/wd/hub/session/bcf5d143-7904-4d9f-8bbb-4d8dc54ec340/element' to command name 'findElement'
[JSONWP Proxy] Proxying [POST /wd/hub/session/bcf5d143-7904-4d9f-8bbb-4d8dc54ec340/element] to [POST http://localhost:8080/session/b88ea738-62a5-4ca2-b324-c837c9de2ee8/element] with body: {"using":"accessibility id","value":"bottom-cell","sessionId":"bcf5d143-7904-4d9f-8bbb-4d8dc54ec340"}
[JSONWP Proxy] Got response with status 200: {"id":"ddc9b0e1-7983-44ce-afc9-6bbd5ab6c6b7","sessionId":"b88ea738-62a5-4ca2-b324-c837c9de2ee8","status":0,"value":{"ELEMENT":"37be62cd-fe1b-4344-b851-1d51fcb499af"}}
[JSONWP Proxy] Replacing sessionId b88ea738-62a5-4ca2-b324-c837c9de2ee8 with bcf5d143-7904-4d9f-8bbb-4d8dc54ec340
[HTTP] <-- POST /wd/hub/session/bcf5d143-7904-4d9f-8bbb-4d8dc54ec340/element 200 47 ms - 166
[HTTP] 
[HTTP] --> POST /wd/hub/session/bcf5d143-7904-4d9f-8bbb-4d8dc54ec340/actions
[HTTP] {"actions":[{"type":"pointer","parameters":{"pointerType":"mouse"},"id":"mouse","actions":[{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"37be62cd-fe1b-4344-b851-1d51fcb499af"}},{"type":"pointerDown","duration":0,"button":0},{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"46d452f2-7f27-4aa4-849c-e1418b125b03"}},{"type":"pointerUp","duration":0,"button":0}]},{"type":"key","id":"key","actions":[{"type":"pause","duration":0},{"type":"pause","duration":0},{"type":"pause","duration":0},{"type":"pause","duration":0}]}],"sessionId":"bcf5d143-7904-4d9f-8bbb-4d8dc54ec340"}
[W3C] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Matched '/wd/hub/session/bcf5d143-7904-4d9f-8bbb-4d8dc54ec340/actions' to command name 'performActions'
[JSONWP Proxy] Proxying [POST /wd/hub/session/bcf5d143-7904-4d9f-8bbb-4d8dc54ec340/actions] to [POST http://localhost:8080/session/b88ea738-62a5-4ca2-b324-c837c9de2ee8/actions] with body: {"actions":[{"type":"pointer","parameters":{"pointerType":"mouse"},"id":"mouse","actions":[{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"37be62cd-fe1b-4344-b851-1d51fcb499af"}},{"type":"pointerDown","duration":0,"button":0},{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"46d452f2-7f27-4aa4-849c-e1418b125b03"}},{"type":"pointerUp","duration":0,"button":0}]},{"type":"key","id":"key","actions":[{"type":"pause","duration":0},{"type":"pause","duration":0},{"type":"pause","duration":0},{"type":"pause","duration":0}]}],"sessionId":"bcf5d143-7904-4d9f-8bbb-4d8dc54ec340"}
[W3C] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: 500 - {"id":"ce8ad25e-0744-4dae-a738-3c2f5fb58a82","sessionId":null,"status":13,"value":"**see above**"}
[W3C]     at JWProxy.proxy$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:182:13)
[W3C]     at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[W3C]     at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
[W3C]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[W3C]     at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[W3C]     at 
[MJSONWP] Matched JSONWP error code 13 to UnknownError
[HTTP] <-- POST /wd/hub/session/bcf5d143-7904-4d9f-8bbb-4d8dc54ec340/actions 500 606 ms - 14800

Finally, if you're curious here's the Appium log for the XCUITest failure

[HTTP] --> POST /wd/hub/session/9e7d9ee4-f347-44a2-81de-82b816b707c2/element
[HTTP] {"using":"accessibility id","value":"top-cell","sessionId":"9e7d9ee4-f347-44a2-81de-82b816b707c2"}
[debug] [W3C] Calling AppiumDriver.findElement() with args: ["accessibility id","top-cell","9e7d9ee4-f347-44a2-81de-82b816b707c2"]
[debug] [XCUITest] Executing command 'findElement'
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
[debug] [BaseDriver] Waiting up to 20000 ms for condition
[debug] [JSONWP Proxy] Matched '/element' to command name 'findElement'
[debug] [JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8100/session/E4460BD0-9950-42B8-AC8D-227C088D2D0E/element] with body: {"using":"accessibility id","value":"top-cell"}
[debug] [JSONWP Proxy] Got response with status 200: {"value":{"ELEMENT":"EE000000-0000-0000-2B22-000000000000"},"sessionId":"E4460BD0-9950-42B8-AC8D-227C088D2D0E","status":0}
[debug] [W3C] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"EE000000-0000-0000-2B22-000000000000"}
[HTTP] <-- POST /wd/hub/session/9e7d9ee4-f347-44a2-81de-82b816b707c2/element 200 315 ms - 88
[HTTP]
[HTTP] --> POST /wd/hub/session/9e7d9ee4-f347-44a2-81de-82b816b707c2/element
[HTTP] {"using":"accessibility id","value":"bottom-cell","sessionId":"9e7d9ee4-f347-44a2-81de-82b816b707c2"}
[debug] [W3C] Calling AppiumDriver.findElement() with args: ["accessibility id","bottom-cell","9e7d9ee4-f347-44a2-81de-82b816b707c2"]
[debug] [XCUITest] Executing command 'findElement'
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
[debug] [BaseDriver] Waiting up to 20000 ms for condition
[debug] [JSONWP Proxy] Matched '/element' to command name 'findElement'
[debug] [JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8100/session/E4460BD0-9950-42B8-AC8D-227C088D2D0E/element] with body: {"using":"accessibility id","value":"bottom-cell"}
[debug] [JSONWP Proxy] Got response with status 200: {"value":{"ELEMENT":"F0000000-0000-0000-2B22-000000000000"},"sessionId":"E4460BD0-9950-42B8-AC8D-227C088D2D0E","status":0}
[debug] [W3C] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"F0000000-0000-0000-2B22-000000000000"}
[HTTP] <-- POST /wd/hub/session/9e7d9ee4-f347-44a2-81de-82b816b707c2/element 200 281 ms - 88
[HTTP]
[HTTP] --> POST /wd/hub/session/9e7d9ee4-f347-44a2-81de-82b816b707c2/actions
[HTTP] {"actions":[{"type":"pointer","parameters":{"pointerType":"mouse"},"id":"mouse","actions":[{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"F0000000-0000-0000-2B22-000000000000"}},{"type":"pointerDown","duration":0,"button":0},{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"EE000000-0000-0000-2B22-000000000000"}},{"type":"pointerUp","duration":0,"button":0}]},{"type":"key","id":"key","actions":[{"type":"pause","duration":0},{"type":"pause","duration":0},{"type":"pause","duration":0},{"type":"pause","duration":0}]}],"sessionId":"9e7d9ee4-f347-44a2-81de-82b816b707c2"}
[debug] [W3C] Calling AppiumDriver.performActions() with args: [[{"type":"pointer","parameters":{"pointerType":"mouse"},"id":"mouse","actions":[{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"F0000000-0000-0000-2B22-000000000000"}},{"type":"pointerDown","duration":0,"button":0},{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"EE000000-0000-0000-2B22-000000000000"}},{"type":"pointerUp","duration":0,"button":0}]},{"type":"key","id":"key","actions":[{"type":"pause","duration":0},{"type":"pause","duration":0},{"type":"pause","duration":0},{"type":"pause","duration":0}]}],"9e7d9ee4-f347-44a2-81de-82b816b707c2"]
[debug] [XCUITest] Executing command 'performActions'
[debug] [XCUITest] Received the following W3C actions: [
[debug] [XCUITest]   {
[debug] [XCUITest]     "type": "pointer",
[debug] [XCUITest]     "parameters": {
[debug] [XCUITest]       "pointerType": "mouse"
[debug] [XCUITest]     },
[debug] [XCUITest]     "id": "mouse",
[debug] [XCUITest]     "actions": [
[debug] [XCUITest]       {
[debug] [XCUITest]         "type": "pointerMove",
[debug] [XCUITest]         "duration": 250,
[debug] [XCUITest]         "x": 0,
[debug] [XCUITest]         "y": 0,
[debug] [XCUITest]         "origin": {
[debug] [XCUITest]           "element-6066-11e4-a52e-4f735466cecf": "F0000000-0000-0000-2B22-000000000000"
[debug] [XCUITest]         }
[debug] [XCUITest]       },
[debug] [XCUITest]       {
[debug] [XCUITest]         "type": "pointerDown",
[debug] [XCUITest]         "duration": 0,
[debug] [XCUITest]         "button": 0
[debug] [XCUITest]       },
[debug] [XCUITest]       {
[debug] [XCUITest]         "type": "pointerMove",
[debug] [XCUITest]         "duration": 250,
[debug] [XCUITest]         "x": 0,
[debug] [XCUITest]         "y": 0,
[debug] [XCUITest]         "origin": {
[debug] [XCUITest]           "element-6066-11e4-a52e-4f735466cecf": "EE000000-0000-0000-2B22-000000000000"
[debug] [XCUITest]         }
[debug] [XCUITest]       },
[debug] [XCUITest]       {
[debug] [XCUITest]         "type": "pointerUp",
[debug] [XCUITest]         "duration": 0,
[debug] [XCUITest]         "button": 0
[debug] [XCUITest]       }
[debug] [XCUITest]     ]
[debug] [XCUITest]   },
[debug] [XCUITest]   {
[debug] [XCUITest]     "type": "key",
[debug] [XCUITest]     "id": "key",
[debug] [XCUITest]     "actions": [
[debug] [XCUITest]       {
[debug] [XCUITest]         "type": "pause",
[debug] [XCUITest]         "duration": 0
[debug] [XCUITest]       },
[debug] [XCUITest]       {
[debug] [XCUITest]         "type": "pause",
[debug] [XCUITest]         "duration": 0
[debug] [XCUITest]       },
[debug] [XCUITest]       {
[debug] [XCUITest]         "type": "pause",
[debug] [XCUITest]         "duration": 0
[debug] [XCUITest]       },
[debug] [XCUITest]       {
[debug] [XCUITest]         "type": "pause",
[debug] [XCUITest]         "duration": 0
[debug] [XCUITest]       }
[debug] [XCUITest]     ]
[debug] [XCUITest]   }
[debug] [XCUITest] ]
[debug] [XCUITest] Preprocessed actions: [
[debug] [XCUITest]   {
[debug] [XCUITest]     "type": "pointer",
[debug] [XCUITest]     "parameters": {
[debug] [XCUITest]       "pointerType": "touch"
[debug] [XCUITest]     },
[debug] [XCUITest]     "id": "mouse",
[debug] [XCUITest]     "actions": [
[debug] [XCUITest]       {
[debug] [XCUITest]         "type": "pointerMove",
[debug] [XCUITest]         "duration": 250,
[debug] [XCUITest]         "x": 0,
[debug] [XCUITest]         "y": 0,
[debug] [XCUITest]         "origin": {
[debug] [XCUITest]           "element-6066-11e4-a52e-4f735466cecf": "F0000000-0000-0000-2B22-000000000000"
[debug] [XCUITest]         }
[debug] [XCUITest]       },
[debug] [XCUITest]       {
[debug] [XCUITest]         "type": "pointerDown",
[debug] [XCUITest]         "duration": 0,
[debug] [XCUITest]         "button": 0
[debug] [XCUITest]       },
[debug] [XCUITest]       {
[debug] [XCUITest]         "type": "pointerMove",
[debug] [XCUITest]         "duration": 250,
[debug] [XCUITest]         "x": 0,
[debug] [XCUITest]         "y": 0,
[debug] [XCUITest]         "origin": {
[debug] [XCUITest]           "element-6066-11e4-a52e-4f735466cecf": "EE000000-0000-0000-2B22-000000000000"
[debug] [XCUITest]         }
[debug] [XCUITest]       },
[debug] [XCUITest]       {
[debug] [XCUITest]         "type": "pointerUp",
[debug] [XCUITest]         "duration": 0,
[debug] [XCUITest]         "button": 0
[debug] [XCUITest]       }
[debug] [XCUITest]     ]
[debug] [XCUITest]   },
[debug] [XCUITest]   {
[debug] [XCUITest]     "type": "key",
[debug] [XCUITest]     "id": "key",
[debug] [XCUITest]     "actions": []
[debug] [XCUITest]   }
[debug] [XCUITest] ]
[debug] [JSONWP Proxy] Matched '/actions' to command name 'performActions'
[debug] [JSONWP Proxy] Proxying [POST /actions] to [POST http://localhost:8100/session/E4460BD0-9950-42B8-AC8D-227C088D2D0E/actions] with body: {"actions":[{"type":"pointer","parameters":{"pointerType":"touch"},"id":"mouse","actions":[{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"F0000000-0000-0000-2B22-000000000000"}},{"type":"pointerDown","duration":0,"button":0},{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"EE000000-0000-0000-2B22-000000000000"}},{"type":"pointerUp","duration":0,"button":0}]},{"type":"key","id":"key","actions":[]}]}
[debug] [JSONWP Proxy] Got response with status 200: {"value":"Error Domain=com.facebook.WebDriverAgent Code=1 \"Only actions of 'pointer' type are supported. 'key' is given instead for action with id 'key'\" UserInfo={NSLocalizedDescription=Only actions of 'pointer' type are supported. 'key' is given instead for action with id 'key'}","sessionId":"E4460BD0-9950-42B8-AC8D-227C088D2D0E","status":13}
[debug] [MJSONWP] Matched JSONWP error code 13 to UnknownError
[debug] [W3C] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Error Domain=com.facebook.WebDriverAgent Code=1 "Only actions of 'pointer' type are supported. 'key' is given instead for action with id 'key'" UserInfo={NSLocalizedDescription=Only actions of 'pointer' type are supported. 'key' is given instead for action with id 'key'}
[debug] [W3C]     at errorFromMJSONWPStatusCode (/Users/gomezju/.nvm/versions/node/v7.3.0/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:789:10)
[debug] [W3C]     at ProxyRequestError.getActualError (/Users/gomezju/.nvm/versions/node/v7.3.0/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:683:14)
[debug] [W3C]     at JWProxy.command$ (/Users/gomezju/.nvm/versions/node/v7.3.0/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:236:19)
[debug] [W3C]     at tryCatch (/Users/gomezju/.nvm/versions/node/v7.3.0/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[debug] [W3C]     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/gomezju/.nvm/versions/node/v7.3.0/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
[debug] [W3C]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Users/gomezju/.nvm/versions/node/v7.3.0/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[debug] [W3C]     at GeneratorFunctionPrototype.invoke (/Users/gomezju/.nvm/versions/node/v7.3.0/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[HTTP] <-- POST /wd/hub/session/9e7d9ee4-f347-44a2-81de-82b816b707c2/actions 500 437 ms - 1969
jlipps commented 6 years ago

Those aren't exactly the right methods to use. Unfortunately docs on this are slim. You probably want to use ActionBuilder:

    actions = ActionBuilder(driver)
    actions.pointer_action.move_to_location(100, 500)
    actions.pointer_action.pointer_down()
    actions.pointer_action.move_to_location(100, 200)
    actions.pointer_action.pointer_up()
    actions.perform()
juandg commented 6 years ago

Thanks @jlipps but unfortunately that didn't work either.

The code above simply clicked on an element on the list but didn't scroll. I added a pause(1) and that worked great on the XCUITest driver and scrolled correctly but gave me the exact same error as above on the Espresso driver. The UIAutomator2 driver fails with NotYetImplementedError: Method has not yet been implemented

My code:

    actions = ActionBuilder(driver)
    actions.pointer_action.move_to_location(100, 500)
    actions.pointer_action.pointer_down()
    actions.pointer_action.pause(1)
    actions.pointer_action.move_to_location(100, 200)
    actions.pointer_action.pointer_up()
    actions.perform()

The appium log with the Espresso driver:

[HTTP] --> POST /wd/hub/session/dccd9e6a-2639-44f9-a8d8-e5191c635c1c/actions
[HTTP] {"actions":[{"type":"pointer","parameters":{"pointerType":"mouse"},"id":"mouse","actions":[{"type":"pointerMove","duration":250,"x":100,"y":500,"origin":"viewport"},{"type":"pointerDown","duration":0,"button":0},{"type":"pause","duration":1000},{"type":"pointerMove","duration":250,"x":100,"y":200,"origin":"viewport"},{"type":"pointerUp","duration":0,"button":0}]}],"sessionId":"dccd9e6a-2639-44f9-a8d8-e5191c635c1c"}
[W3C] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Matched '/wd/hub/session/dccd9e6a-2639-44f9-a8d8-e5191c635c1c/actions' to command name 'performActions'
[JSONWP Proxy] Proxying [POST /wd/hub/session/dccd9e6a-2639-44f9-a8d8-e5191c635c1c/actions] to [POST http://localhost:8080/session/9d4737b6-b865-4377-a225-75a83fe49a97/actions] with body: {"actions":[{"type":"pointer","parameters":{"pointerType":"mouse"},"id":"mouse","actions":[{"type":"pointerMove","duration":250,"x":100,"y":500,"origin":"viewport"},{"type":"pointerDown","duration":0,"button":0},{"type":"pause","duration":1000},{"type":"pointerMove","duration":250,"x":100,"y":200,"origin":"viewport"},{"type":"pointerUp","duration":0,"button":0}]}],"sessionId":"dccd9e6a-2639-44f9-a8d8-e5191c635c1c"}
[W3C] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: 500 - {"id":"c476153c-fcf2-4cde-9708-977b324ffaae","sessionId":null,"status":13,"value":"java.lang.RuntimeException: java.lang.reflect.InvocationTargetException\n\tat android.support.test.espresso.base.Interrogator.getNextMessage(Interrogator.java:212)\n\tat android.support.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:152)\n\tat android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:472)\n\tat android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:419)\n\tat android.support.test.espresso.base.UiControllerImpl.injectMotionEvent(UiControllerImpl.java:240)\n\tat io.appium.espressoserver.lib.helpers.w3c.adapter.espresso.MotionEventBuilder$MotionEventRunner.run(MotionEventBuilder.java:196)\n\tat io.appium.espressoserver.lib.helpers.w3c.adapter.espresso.AndroidMotionEvent.pointerEvent(AndroidMotionEvent.java:53)\n\tat io.appium.espressoserver.lib.helpers.w3c.adapter.espresso.EspressoW3CActionAdapter.pointerUp(EspressoW3CActionAdapter.java:312)\n\tat io.appium.espressoserver.lib.helpers.w3c.dispatcher.PointerDispatch.dispatchPointerEvent(PointerDispatch.java:72)\n\tat io.appium.espressoserver.lib.helpers.w3c.dispatcher.PointerDispatch.dispatchPointerUp(PointerDispatch.java:116)\n\tat io.appium.espressoserver.lib.helpers.w3c.models.ActionObject.dispatch(ActionObject.java:127)\n\tat io.appium.espressoserver.lib.helpers.w3c.models.Tick.dispatchAll(Tick.java:72)\n\tat io.appium.espressoserver.lib.helpers.w3c.models.ActionSequence.dispatch(ActionSequence.java:86)\n\tat io.appium.espressoserver.lib.helpers.w3c.models.Actions.perform(Actions.java:56)\n\tat io.appium.espressoserver.lib.handlers.PeformActions$1.run(PeformActions.java:21)\n\tat io.appium.espressoserver.lib.handlers.PeformActions$1.run(PeformActions.java:17)\n\tat io.appium.espressoserver.lib.viewaction.UiControllerPerformer.perform(UiControllerPerformer.java:43)\n\tat android.support.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:356)\n\tat android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:241)\n\tat android.support.test.espresso.ViewInteraction.access$100(ViewInteraction.java:62)\n\tat android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:149)\n\tat android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:146)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat android.os.Handler.handleCallback(Handler.java:789)\n\tat android.os.Handler.dispatchMessage(Handler.java:98)\n\tat android.os.Looper.loop(Looper.java:164)\n\tat android.app.ActivityThread.main(ActivityThread.java:6541)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)\nCaused by: java.lang.reflect.InvocationTargetException\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat android.support.test.espresso.base.Interrogator.getNextMessage(Interrogator.java:206)\n\t... 29 more\nCaused by: java.lang.IllegalArgumentException: pointerIndex out of range\n\tat android.view.MotionEvent.nativeGetAxisValue(Native Method)\n\tat android.view.MotionEvent.getY(MotionEvent.java:2216)\n\tat android.widget.ScrollView.onSecondaryPointerUp(ScrollView.java:780)\n\tat android.widget.ScrollView.onInterceptTouchEvent(ScrollView.java:600)\n\tat com.facebook.react.views.scroll.ReactScrollView.onInterceptTouchEvent(ReactScrollView.java:183)\n\tat android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2504)\n\tat android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)\n\tat android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)\n\tat android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)\n\tat android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)\n\tat android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2983)\n\tat android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)\n\tat android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)\n\tat android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)\n\tat android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)\n\tat android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)\n\tat android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)\n\tat android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)\n\tat android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)\n\tat android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)\n\tat android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)\n\tat android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)\n\tat com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:445)\n\tat com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1828)\n\tat android.app.Activity.dispatchTouchEvent(Activity.java:3292)\n\tat com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:407)\n\tat android.view.View.dispatchPointerEvent(View.java:11964)\n\tat android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4776)\n\tat android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4590)\n\tat android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)\n\tat android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)\n\tat android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)\n\tat android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4274)\n\tat android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)\n\tat android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4331)\n\tat android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)\n\tat android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)\n\tat android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)\n\tat android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)\n\tat android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)\n\tat android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6642)\n\tat android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6616)\n\tat android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6577)\n\tat android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6745)\n\tat android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)\n\tat android.os.MessageQueue.nativePollOnce(Native Method)\n\tat android.os.MessageQueue.next(MessageQueue.java:325)\n\t... 31 more\n"}
[W3C]     at JWProxy.proxy$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:182:13)
[W3C]     at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[W3C]     at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
[W3C]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[W3C]     at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[W3C]     at 
[MJSONWP] Matched JSONWP error code 13 to UnknownError
[HTTP] <-- POST /wd/hub/session/dccd9e6a-2639-44f9-a8d8-e5191c635c1c/actions 500 1649 ms - 14800

Java stacktace:

selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at android.support.test.espresso.base.Interrogator.getNextMessage(Interrogator.java:212)
    at android.support.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:152)
    at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:472)
    at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:419)
    at android.support.test.espresso.base.UiControllerImpl.injectMotionEvent(UiControllerImpl.java:240)
    at io.appium.espressoserver.lib.helpers.w3c.adapter.espresso.MotionEventBuilder$MotionEventRunner.run(MotionEventBuilder.java:196)
    at io.appium.espressoserver.lib.helpers.w3c.adapter.espresso.AndroidMotionEvent.pointerEvent(AndroidMotionEvent.java:53)
    at io.appium.espressoserver.lib.helpers.w3c.adapter.espresso.EspressoW3CActionAdapter.pointerUp(EspressoW3CActionAdapter.java:312)
    at io.appium.espressoserver.lib.helpers.w3c.dispatcher.PointerDispatch.dispatchPointerEvent(PointerDispatch.java:72)
    at io.appium.espressoserver.lib.helpers.w3c.dispatcher.PointerDispatch.dispatchPointerUp(PointerDispatch.java:116)
    at io.appium.espressoserver.lib.helpers.w3c.models.ActionObject.dispatch(ActionObject.java:127)
    at io.appium.espressoserver.lib.helpers.w3c.models.Tick.dispatchAll(Tick.java:72)
    at io.appium.espressoserver.lib.helpers.w3c.models.ActionSequence.dispatch(ActionSequence.java:86)
    at io.appium.espressoserver.lib.helpers.w3c.models.Actions.perform(Actions.java:56)
    at io.appium.espressoserver.lib.handlers.PeformActions$1.run(PeformActions.java:21)
    at io.appium.espressoserver.lib.handlers.PeformActions$1.run(PeformActions.java:17)
    at io.appium.espressoserver.lib.viewaction.UiControllerPerformer.perform(UiControllerPerformer.java:43)
    at android.support.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:356)
    at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:241)
    at android.support.test.espresso.ViewInteraction.access$100(ViewInteraction.java:62)
    at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:149)
    at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:146)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at android.support.test.espresso.base.Interrogator.getNextMessage(Interrogator.java:206)
    ... 29 more
Caused by: java.lang.IllegalArgumentException: pointerIndex out of range
    at android.view.MotionEvent.nativeGetAxisValue(Native Method)
    at android.view.MotionEvent.getY(MotionEvent.java:2216)
    at android.widget.ScrollView.onSecondaryPointerUp(ScrollView.java:780)
    at android.widget.ScrollView.onInterceptTouchEvent(ScrollView.java:600)
    at com.facebook.react.views.scroll.ReactScrollView.onInterceptTouchEvent(ReactScrollView.java:183)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2504)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2983)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
    at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:445)
    at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1828)
    at android.app.Activity.dispatchTouchEvent(Activity.java:3292)
    at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:407)
    at android.view.View.dispatchPointerEvent(View.java:11964)
    at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4776)
    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4590)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4274)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4331)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
    at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6642)
    at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6616)
    at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6577)
    at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6745)
    at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:325)
    ... 31 more
jlipps commented 6 years ago

OK, I think this is now an error that @dpgraham can look into since he developed the actions functionality in the espresso driver.

dpgraham commented 6 years ago

Looking at the logs for the W3C actions I can see right away that it's using the Mouse and not touch:

{
    "actions": [{
        "type": "pointer",
        "parameters": {
            "pointerType": "mouse"
        },
        "id": "mouse",
        "actions": [{
            "type": "pointerMove",
            "duration": 250,
            "x": 0,
            "y": 0,
            "origin": {
                "element-6066-11e4-a52e-4f735466cecf": "37be62cd-fe1b-4344-b851-1d51fcb499af"
            }
        }, {
            "type": "pointerDown",
            "duration": 0,
            "button": 0
        }, {
            "type": "pointerMove",
            "duration": 250,
            "x": 0,
            "y": 0,
            "origin": {
                "element-6066-11e4-a52e-4f735466cecf": "46d452f2-7f27-4aa4-849c-e1418b125b03"
            }
        }, {
            "type": "pointerUp",
            "duration": 0,
            "button": 0
        }]
    }, {
        "type": "key",
        "id": "key",
        "actions": [{
            "type": "pause",
            "duration": 0
        }, {
            "type": "pause",
            "duration": 0
        }, {
            "type": "pause",
            "duration": 0
        }, {
            "type": "pause",
            "duration": 0
        }]
    }],
    "sessionId": "bcf5d143-7904-4d9f-8bbb-4d8dc54ec340"
}

Is there a way to set the pointerType to 'touch'? Does the client support that?

As for the legacy touch actions, it should be working so there must be a bug. The way we made it work is just by taking legacy touch actions and then translating them to what should be equivalent W3C touch actions.

@juandg Can you try running logcat (adb logcat) and then when you run the touch actions, get the logs for when it happens? The Appium logs start with appium.

dpgraham commented 6 years ago

@juandg This is unrelated to this bug, but for your test are you trying to scroll to an element that's offscreen?

If you are, and that element has the accessibility ID set, you should be able to locate elements by their accessibility id when they're offscreen (Espresso only).

juandg commented 6 years ago

Hi @dpgraham thanks for your quick response. I noticed I'm able to locate the element even though it's not visible which is awesome, but in this particular scenario I want to perform an action on it (like clicking it) and those fail with this error: Action will not be performed because the target view does not match one or more of the following constraints: at least 90 percent of the view's area is displayed to the user.

That's the reason I need to scroll to the element in this particular case. I'll try capturing the adb logs and post them here

dpgraham commented 6 years ago

Okay, I can reproduce it myself as well, so I'll dig into this. (spoke too soon... I wasn't able to repro it)

One thing to note is that the element actually gets scrolled to when you find the element. So if you just locate the element (and don't do anything) it should scroll to the element.

juandg commented 6 years ago

Ok here's the relevant part of the logcat output:

10-12 15:58:09.476 22906 23081 D appium  : Started processing POST request for '/session/f3f995dd-5f4e-417e-a27c-500cb271b102/actions'
10-12 15:58:09.477 22906 23081 D appium  : Matched route definition: class io.appium.espressoserver.lib.http.RouteDefinition
10-12 15:58:09.477 22906 23081 D appium  : Matched route handler: class io.appium.espressoserver.lib.handlers.PeformActions
10-12 15:58:09.477 22906 23081 D appium  : Got raw post data: {"actions":[{"type":"pointer","parameters":{"pointerType":"mouse"},"id":"mouse","actions":[{"type":"pointerMove","duration":250,"x":100,"y":500,"origin":"viewport"},{"type":"pointerDown","duration":0,"button":0},{"type":"pause","duration":1000},{"type":"pointerMove","duration":250,"x":100,"y":200,"o...
10-12 15:58:09.493 22906 22906 I ViewInteraction: Performing 'getting view in application' action on view is a root view.
10-12 15:58:09.496 22906 23081 I appium  : Performing W3C actions sequence
10-12 15:58:09.499 22906 22906 I ViewInteraction: Performing 'applying W3C actions ' action on view Looked for element with View DecorView@649a14b[MainActivity]
10-12 15:58:09.502 22906 22906 I appium  : Performing actions
10-12 15:58:09.505 22906 22906 I appium  : Dispatching tick #1 of 5
10-12 15:58:09.505 22906 22906 I appium  : Dispatching action #1 of input source mouse
10-12 15:58:09.506 22906 22906 I appium  : Dispatching pointer move 'TOUCH' on input source with id 'mouse' with origin 'io.appium.espressoserver.lib.helpers.w3c.models.Origin@cb1bcbf' and coordinates [100, 500]
10-12 15:58:09.506 22906 22906 I appium  : Origin type is: viewport
10-12 15:58:09.509 22906 22906 I appium  : State of pointer input source with id mouse is now: pointer-type=[null] x=[0] y=[0] pressed=[[]]
10-12 15:58:09.509 22906 22906 I appium  : Pointer event: Tick complete
10-12 15:58:09.527 22906 22906 I appium  : Running pointer move at coordinates: 6 30 TOUCH
10-12 15:58:09.536 22906 22906 I appium  : Running pointer move at coordinates: 10 48 TOUCH
10-12 15:58:09.542 22906 22906 I appium  : Running pointer move at coordinates: 12 62 TOUCH
10-12 15:58:09.549 22906 22906 I appium  : Running pointer move at coordinates: 15 76 TOUCH
10-12 15:58:09.557 22906 22906 I appium  : Running pointer move at coordinates: 18 88 TOUCH
10-12 15:58:09.564 22906 22906 I appium  : Running pointer move at coordinates: 21 104 TOUCH
10-12 15:58:09.570 22906 22906 I appium  : Running pointer move at coordinates: 24 118 TOUCH
10-12 15:58:09.577 22906 22906 I appium  : Running pointer move at coordinates: 26 130 TOUCH
10-12 15:58:09.583 22906 22906 I appium  : Running pointer move at coordinates: 29 144 TOUCH
10-12 15:58:09.590 22906 22906 I appium  : Running pointer move at coordinates: 32 158 TOUCH
10-12 15:58:09.597 22906 22906 I appium  : Running pointer move at coordinates: 34 170 TOUCH
10-12 15:58:09.604 22906 22906 I appium  : Running pointer move at coordinates: 37 186 TOUCH
10-12 15:58:09.611 22906 22906 I appium  : Running pointer move at coordinates: 40 200 TOUCH
10-12 15:58:09.620 22906 22906 I appium  : Running pointer move at coordinates: 43 214 TOUCH
10-12 15:58:09.628 22906 22906 I appium  : Running pointer move at coordinates: 46 230 TOUCH
10-12 15:58:09.635 22906 22906 I appium  : Running pointer move at coordinates: 49 246 TOUCH
10-12 15:58:09.643 22906 22906 I appium  : Running pointer move at coordinates: 52 262 TOUCH
10-12 15:58:09.650 22906 22906 I appium  : Running pointer move at coordinates: 55 276 TOUCH
10-12 15:58:09.658 22906 22906 I appium  : Running pointer move at coordinates: 58 290 TOUCH
10-12 15:58:09.664 22906 22906 I appium  : Running pointer move at coordinates: 61 306 TOUCH
10-12 15:58:09.671 22906 22906 I appium  : Running pointer move at coordinates: 64 320 TOUCH
10-12 15:58:09.679 22906 22906 I appium  : Running pointer move at coordinates: 67 334 TOUCH
10-12 15:58:09.687 22906 22906 I appium  : Running pointer move at coordinates: 70 350 TOUCH
10-12 15:58:09.693 22906 22906 I appium  : Running pointer move at coordinates: 73 364 TOUCH
10-12 15:58:09.699 22906 22906 I appium  : Running pointer move at coordinates: 75 376 TOUCH
10-12 15:58:09.705 22906 22906 I appium  : Running pointer move at coordinates: 78 388 TOUCH
10-12 15:58:09.711 22906 22906 I appium  : Running pointer move at coordinates: 80 400 TOUCH
10-12 15:58:09.718 22906 22906 I appium  : Running pointer move at coordinates: 83 414 TOUCH
10-12 15:58:09.725 22906 22906 I appium  : Running pointer move at coordinates: 85 426 TOUCH
10-12 15:58:09.732 22906 22906 I appium  : Running pointer move at coordinates: 88 440 TOUCH
10-12 15:58:09.738 22906 22906 I appium  : Running pointer move at coordinates: 91 454 TOUCH
10-12 15:58:09.744 22906 22906 I appium  : Running pointer move at coordinates: 93 466 TOUCH
10-12 15:58:09.751 22906 22906 I appium  : Running pointer move at coordinates: 96 478 TOUCH
10-12 15:58:09.757 22906 22906 I appium  : Running pointer move at coordinates: 98 492 TOUCH
10-12 15:58:09.763 22906 22906 I appium  : Running pointer move at coordinates: 100 500 TOUCH
10-12 15:58:09.782 22906 22906 I appium  : Dispatching tick #2 of 5
10-12 15:58:09.784 22906 22906 I appium  : Dispatching action #2 of input source mouse
10-12 15:58:09.784 22906 22906 I appium  : Dispatching pointer event 'pointerDown' on input source with id 'mouse' with coordinates [100, 500] and button '0'
10-12 15:58:09.785 22906 22906 I appium  : Running pointer down at coordinates: 100 500
10-12 15:58:09.802 22906 22906 I appium  : State of pointer input source with id mouse is now: pointer-type=[null] x=[100] y=[500] pressed=[[0]]
10-12 15:58:09.802 22906 22906 I appium  : Pointer event: Tick complete
10-12 15:58:09.803 22906 22906 I appium  : Dispatching tick #3 of 5
10-12 15:58:09.803 22906 22906 I appium  : Dispatching action #3 of input source mouse
10-12 15:58:09.803 22906 22906 I appium  : Dispatching pause event for 1000 milliseconds
10-12 15:58:09.803 22906 22906 I appium  : Pointer event: Tick complete
10-12 15:58:09.803 22906 22906 I appium  : Wait for tick to finish for 999 ms
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge: Could not detect idle state.
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge: java.util.concurrent.TimeoutException: No idle state with idle timeout: 500 within global timeout: 10000
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at android.app.UiAutomation.waitForIdle(UiAutomation.java:661)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at com.android.uiautomator.core.UiAutomatorBridge.waitForIdle(UiAutomatorBridge.java:96)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at com.android.uiautomator.core.UiAutomatorBridge.waitForIdle(UiAutomatorBridge.java:91)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at com.android.uiautomator.core.QueryController.findAccessibilityNodeInfo(QueryController.java:143)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at com.android.uiautomator.core.QueryController.findAccessibilityNodeInfo(QueryController.java:138)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at com.android.uiautomator.core.UiObject.findAccessibilityNodeInfo(UiObject.java:171)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at com.android.uiautomator.core.UiObject.waitForExists(UiObject.java:855)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at com.android.uiautomator.core.UiObject.exists(UiObject.java:906)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at com.android.uiautomator.common.UiWatchers$3.checkForCondition(UiWatchers.java:87)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at com.android.uiautomator.core.UiDevice.runWatchers(UiDevice.java:560)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at com.android.uiautomator.core.UiObject.findAccessibilityNodeInfo(UiObject.java:176)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at com.android.uiautomator.core.UiObject.waitForExists(UiObject.java:855)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at com.android.uiautomator.core.UiObject.exists(UiObject.java:906)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at io.appium.android.bootstrap.utils.TheWatchers.isDialogPresent(TheWatchers.java:51)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at io.appium.android.bootstrap.utils.TheWatchers.check(TheWatchers.java:42)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at io.appium.android.bootstrap.SocketServer$1.run(SocketServer.java:140)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at java.util.TimerThread.mainLoop(Timer.java:555)
10-12 15:58:10.311 21285 21340 W UiAutomatorBridge:     at java.util.TimerThread.run(Timer.java:505)
10-12 15:58:10.806 22906 22906 I appium  : Dispatching tick #4 of 5
10-12 15:58:10.806 22906 22906 I appium  : Dispatching action #4 of input source mouse
10-12 15:58:10.807 22906 22906 I appium  : Dispatching pointer move 'TOUCH' on input source with id 'mouse' with origin 'io.appium.espressoserver.lib.helpers.w3c.models.Origin@3489b51' and coordinates [100, 200]
10-12 15:58:10.807 22906 22906 I appium  : Origin type is: viewport
10-12 15:58:10.807 22906 22906 I appium  : State of pointer input source with id mouse is now: pointer-type=[null] x=[100] y=[500] pressed=[[0]]
10-12 15:58:10.807 22906 22906 I appium  : Pointer event: Tick complete
10-12 15:58:10.815 22906 22906 I appium  : Running pointer move at coordinates: 100 498 TOUCH
10-12 15:58:10.821 22906 22906 I appium  : Running pointer move at coordinates: 100 488 TOUCH
10-12 15:58:10.829 22906 22906 I appium  : Running pointer move at coordinates: 100 481 TOUCH
10-12 15:58:10.836 22906 22906 I appium  : Running pointer move at coordinates: 100 472 TOUCH
10-12 15:58:10.843 22906 22906 I appium  : Running pointer move at coordinates: 100 464 TOUCH
10-12 15:58:10.850 22906 22906 I appium  : Running pointer move at coordinates: 100 456 TOUCH
10-12 15:58:10.859 22906 22906 I appium  : Running pointer move at coordinates: 100 447 TOUCH
10-12 15:58:10.865 22906 22906 I appium  : Running pointer move at coordinates: 100 436 TOUCH
10-12 15:58:10.873 22906 22906 I appium  : Running pointer move at coordinates: 100 428 TOUCH
10-12 15:58:10.880 22906 22906 I appium  : Running pointer move at coordinates: 100 418 TOUCH
10-12 15:58:10.888 22906 22906 I appium  : Running pointer move at coordinates: 100 410 TOUCH
10-12 15:58:10.895 22906 22906 I appium  : Running pointer move at coordinates: 100 402 TOUCH
10-12 15:58:10.902 22906 22906 I appium  : Running pointer move at coordinates: 100 393 TOUCH
10-12 15:58:10.909 22906 22906 I appium  : Running pointer move at coordinates: 100 385 TOUCH
10-12 15:58:10.916 22906 22906 I appium  : Running pointer move at coordinates: 100 376 TOUCH
10-12 15:58:10.924 22906 22906 I appium  : Running pointer move at coordinates: 100 368 TOUCH
10-12 15:58:10.931 22906 22906 I appium  : Running pointer move at coordinates: 100 358 TOUCH
10-12 15:58:10.938 22906 22906 I appium  : Running pointer move at coordinates: 100 350 TOUCH
10-12 15:58:10.946 22906 22906 I appium  : Running pointer move at coordinates: 100 342 TOUCH
10-12 15:58:10.953 22906 22906 I appium  : Running pointer move at coordinates: 100 331 TOUCH
10-12 15:58:10.960 22906 22906 I appium  : Running pointer move at coordinates: 100 324 TOUCH
10-12 15:58:10.967 22906 22906 I appium  : Running pointer move at coordinates: 100 314 TOUCH
10-12 15:58:10.974 22906 22906 I appium  : Running pointer move at coordinates: 100 306 TOUCH
10-12 15:58:10.982 22906 22906 I appium  : Running pointer move at coordinates: 100 296 TOUCH
10-12 15:58:10.990 22906 22906 I appium  : Running pointer move at coordinates: 100 288 TOUCH
10-12 15:58:10.997 22906 22906 I appium  : Running pointer move at coordinates: 100 279 TOUCH
10-12 15:58:11.004 22906 22906 I appium  : Running pointer move at coordinates: 100 271 TOUCH
10-12 15:58:11.011 22906 22906 I appium  : Running pointer move at coordinates: 100 262 TOUCH
10-12 15:58:11.019 22906 22906 I appium  : Running pointer move at coordinates: 100 254 TOUCH
10-12 15:58:11.026 22906 22906 I appium  : Running pointer move at coordinates: 100 244 TOUCH
10-12 15:58:11.032 22906 22906 I appium  : Running pointer move at coordinates: 100 236 TOUCH
10-12 15:58:11.039 22906 22906 I appium  : Running pointer move at coordinates: 100 228 TOUCH
10-12 15:58:11.047 22906 22906 I appium  : Running pointer move at coordinates: 100 220 TOUCH
10-12 15:58:11.053 22906 22906 I appium  : Running pointer move at coordinates: 100 211 TOUCH
10-12 15:58:11.060 22906 22906 I appium  : Running pointer move at coordinates: 100 204 TOUCH
10-12 15:58:11.067 22906 22906 I appium  : Running pointer move at coordinates: 100 200 TOUCH
10-12 15:58:11.074 22906 22906 I appium  : Dispatching tick #5 of 5
10-12 15:58:11.074 22906 22906 I appium  : Dispatching action #5 of input source mouse
10-12 15:58:11.074 22906 22906 I appium  : Dispatching pointer event 'pointerUp' on input source with id 'mouse' with coordinates [100, 200] and button '0'
10-12 15:58:11.075 22906 22906 I appium  : Running pointer up at coordinates: 100 200
10-12 15:58:11.078 22906 22906 E InputEventReceiver: Exception dispatching input event.
10-12 15:58:11.078 22906 22906 E MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI: java.lang.IllegalArgumentException: pointerIndex out of range
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.MotionEvent.nativeGetAxisValue(Native Method)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.MotionEvent.getY(MotionEvent.java:2216)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.widget.ScrollView.onSecondaryPointerUp(ScrollView.java:780)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.widget.ScrollView.onInterceptTouchEvent(ScrollView.java:600)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at com.facebook.react.views.scroll.ReactScrollView.onInterceptTouchEvent(ReactScrollView.java:183)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2504)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2983)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:445)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1828)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.app.Activity.dispatchTouchEvent(Activity.java:3292)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:407)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.View.dispatchPointerEvent(View.java:11964)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4776)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4590)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4274)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4331)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6642)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6616)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6577)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6745)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.os.MessageQueue.nativePollOnce(Native Method)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.os.MessageQueue.next(MessageQueue.java:325)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at java.lang.reflect.Method.invoke(Native Method)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.support.test.espresso.base.Interrogator.getNextMessage(Interrogator.java:206)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.support.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:152)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:472)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:419)
10-12 15:58:11.102 22906 22906 E MessageQueue-JNI:  at android.support.test.espresso.base.UiControllerImpl.injectMotionEvent(UiCo
10-12 15:58:11.103 22906 22906 W UiControllerImpl: ignoring signal of: MOTION_INJECTION_HAS_COMPLETED from previous generation: 238 current generation: 239
10-12 15:58:11.125 22906 23081 I appium  : Responding to server with error: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
10-12 15:58:11.125 22906 23081 I appium  :  at android.support.test.espresso.base.Interrogator.getNextMessage(Interrogator.java:212)
10-12 15:58:11.125 22906 23081 I appium  :  at android.support.test.espresso.base.Interrogator.loopAndInterrogate(Interrogator.java:152)
10-12 15:58:11.125 22906 23081 I appium  :  at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:472)
10-12 15:58:11.125 22906 23081 I appium  :  at android.support.test.espresso.base.UiControllerImpl.loopUntil(UiControllerImpl.java:419)
10-12 15:58:11.125 22906 23081 I appium  :  at android.support.test.espresso.base.UiControllerImpl.injectMotionEvent(UiControllerImpl.java:240)
10-12 15:58:11.125 22906 23081 I appium  :  at io.appium.espressoserver.lib.helpers.w3c.adapter.espresso.MotionEventBuilder$MotionEventRunner.run(MotionEventBuilder.java:196)
10-12 15:58:11.125 22906 23081 I appium  :  at io.appium.espressoserver.lib.helpers.w3c.adapter.espresso.AndroidMotionEvent.pointerEvent(AndroidMotionEvent.java:53)
10-12 15:58:11.125 22906 23081 I appium  :  at io.appium.espressoserver.lib.helpers.w3c.adapter.espresso.EspressoW3CActionAdapter.pointerUp(EspressoW3CActionAdapter.java:312)
10-12 15:58:11.125 22906 23081 I appium  :  at io.appium.espressoserver.lib.helpers.w3c.dispatcher.PointerDispatch.dispatchPointerEvent(PointerDispatch.java:72)
10-12 15:58:11.125 22906 23081 I appium  :  at io.appium.espressoserver.lib.helpers.w3c.dispatcher.PointerDispatch.dispatchPointerUp(PointerDispatch.java:116)
10-12 15:58:11.125 22906 23081 I appium  :  at io.appium.espressoserver.lib.helpers.w3c.models.ActionObject.dispatch(ActionObject.java:127)
10-12 15:58:11.125 22906 23081 I appium  :  at io.appium.espressoserver.lib.helpers.w3c.models.Tick.dispatchAll(Tick.java:72)
10-12 15:58:11.125 22906 23081 I appium  :  at io.appium.espressoserver.lib.helpers.w3c.models.ActionSequence.dispatch(ActionSequence.java:86)
10-12 15:58:11.125 22906 23081 I appium  :  at io.appium.espressoserver.lib.helpers.w3c.models.Actions.perform(Actions.java:56)
10-12 15:58:11.125 22906 23081 I appium  :  at io.appium.espressoserver.lib.handlers.PeformActions$1.run(PeformActions.java:21)
10-12 15:58:11.125 22906 23081 I appium  :  at io.appium.espressoserver.lib.handlers.PeformActions$1.run(PeformActions.java:17)
10-12 15:58:11.125 22906 23081 I appium  :  at io.appium.espressoserver.lib.viewaction.UiControllerPerformer.perform(UiControllerPerformer.java:43)
10-12 15:58:11.125 22906 23081 I appium  :  at android.support.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:356)
10-12 15:58:11.125 22906 23081 I appium  :  at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:241)
10-12 15:58:11.125 22906 23081 I appium  :  at android.support.test.espresso.ViewInteraction.access$100(ViewInteraction.java:62)
10-12 15:58:11.125 22906 23081 I appium  :  at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:149)
10-12 15:58:11.125 22906 23081 I appium  :  at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:146)
10-12 15:58:11.125 22906 23081 I appium  :  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
10-12 15:58:11.125 22906 23081 I appium  :  at android.os.Handler.handleCallback(Handler.java:789)
10-12 15:58:11.125 22906 23081 I appium  :  at android.os.Handler.dispatchMessage(Handler.java:98)
10-12 15:58:11.125 22906 23081 I appium  :  at android.os.Looper.loop(Looper.java:164)
10-12 15:58:11.125 22906 23081 I appium  :  at android.app.ActivityThread.main(ActivityThread.java:6541)
10-12 15:58:11.125 22906 23081 I appium  :  at java.lang.reflect.Method.invoke(Native Method)
10-12 15:58:11.125 22906 23081 I appium  :  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
10-12 15:58:11.125 22906 23081 I appium  :  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
10-12 15:58:11.125 22906 23081 I appium  : Caused by: java.lang.reflect.InvocationTargetException
10-12 15:58:11.125 22906 23081 I appium  :  at java.lang.reflect.Method.invoke(Native Method)
10-12 15:58:11.125 22906 23081 I appium  :  at android.support.test.espresso.base.Interrogator.getNextMessage(Interrogator.java:206)
10-12 15:58:11.125 22906 23081 I appium  :  ... 29 more
10-12 15:58:11.125 22906 23081 I appium  : Caused by: java.lang.IllegalArgumentException: pointerIndex out of range
10-12 15:58:11.125 22906 23081 I appium  :  at android.view.MotionEvent.nativeGetAxisValue(Native Method)
10-12 15:58:11.125 22906 23081 I appium  :  at android.view.MotionEvent.getY(MotionEvent.java:2216)
10-12 15:58:11.125 22906 23081 I appium  :  at android.widget.ScrollView.onSecondaryPointerUp(ScrollView.java:780)
10-12 15:58:11.125 22906 23081 I appium  :  at android.widget.ScrollView.onInterceptTouchEvent(ScrollView.java:600)
10-12 15:58:11.125 22906 23081 I appium  :  at com.facebook.react.views.scroll.ReactScrollView.onInterceptTouchEvent(ReactScrollView.java:183)
10-12 15:58:11.125 22906 23081 I appium  :  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2504)
10-12 15:58:11.125 22906 23081 I appium  :  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
10-12 15:58:11.125 22906 23081 I appium  :  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
10-12 15:58:11.125 22906 23081 I appium  :  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
10-12 15:58:11.125 22906 23081 I appium  :  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
10-12 15:58:11.125 22906 23081 I appium  :  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2983)
10-12 15:58:11.125 22906 23081 I appium  :  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
10-12 15:58:11.125 22906 23081 I appium  :  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
10-12 15:58:11.125 22906 23081 I appium  :  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2650)
10-12 15:58:11.125 22906 23081 I appium  :  at androi
10-12 15:58:11.200 22906 23081 D appium  : Started processing DELETE request for '/session/f3f995dd-5f4e-417e-a27c-500cb271b102'
10-12 15:58:11.200 22906 23081 D appium  : Matched route definition: class io.appium.espressoserver.lib.http.RouteDefinition
10-12 15:58:11.200 22906 23081 D appium  : Matched route handler: class io.appium.espressoserver.lib.handlers.DeleteSession
10-12 15:58:11.210 22906 23081 D appium  : Finished processing DELETE request for '/session/f3f995dd-5f4e-417e-a27c-500cb271b102'
10-12 15:58:11.210 22906 23081 I appium  : Responding to server with value: null
juandg commented 6 years ago

@dpgraham Interesting, how should I "find" the element?

I tried using these 2 separate strategies to find the element and indeed the element is found (even though it's off screen) but the UI never scrolls to that position.

   driver.find_elements_by_accessibility_id('my-button')
   driver.find_element(MobileBy.ACCESSIBILITY_ID, 'my-button')
saikrishna321 commented 6 years ago

@juandg ActionsBuilder from selenium is not gonna work for you. It build a wrong W3C Action chain which will not work (https://github.com/appium/appium-espresso-driver/issues/244#issuecomment-429475141)

Please use Point API and build your actions.

Sample Point API for DragNDrop in java

Point source = dragMe.getCenter();
        Point target = driver.findElementByAccessibilityId("dropzone").getCenter();
        PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
        Sequence dragNDrop = new Sequence(finger, 1);
        dragNDrop.addAction(finger.createPointerMove(Duration.ofMillis(0),
                PointerInput.Origin.viewport(), source.x, source.y));
        dragNDrop.addAction(finger.createPointerDown(PointerInput.MouseButton.MIDDLE.asArg()));
        dragNDrop.addAction(new Pause(finger, Duration.ofMillis(600)));
        dragNDrop.addAction(finger.createPointerMove(Duration.ofMillis(600),
                PointerInput.Origin.viewport(),
                target.x, target.y));
        dragNDrop.addAction(finger.createPointerUp(PointerInput.MouseButton.MIDDLE.asArg()));
        driver.perform(Arrays.asList(dragNDrop));

Pause is mandatory as WDA expects that

https://github.com/appium/WebDriverAgent/blob/master/WebDriverAgentTests/IntegrationTests/FBW3CTouchActionsIntegrationTests.m

dpgraham commented 6 years ago

@juandg is there more than one element with the id my-button?

dpgraham commented 6 years ago

I'm pretty sure the problem is that it's dispatching MOUSE events instead of TOUCH events. I'll try putting in a patch for this.

juandg commented 6 years ago

@jlipps, @dpgraham, @saikrishna321:

Ultimately you were right and the issue was the fact that the Python client was dispatching Mouse events instead of Touch events.

The confusing part is that most content on the web related to Appium and the Python client directs you towards TouchAction or sometimes ActionChains and those work reliably on other Appium drivers like XCUITest and UIAutomator2 so for people migrating from those is confusing that Espresso behaves differently.

To solve my issue I converted @saikrishna321's Java code into the equivalent for the Python client and this finally issued the correct W3C action chain that made the Espresso driver scroll and bring the button I needed to click into view. (this also worked on the XCUITest driver)

Here's my Python code:

    swipe_end = session.get_element('top-cell')
    swipe_start = session.get_element('bottom-cell')
    finger = PointerInput('touch', 'finger')
    actions = ActionBuilder(driver, mouse=finger)
    actions.pointer_action.move_to(swipe_start)
    actions.pointer_action.pointer_down(button=MouseButton.MIDDLE)
    actions.pointer_action.pause(1)
    actions.pointer_action.move_to(swipe_end)
    actions.pointer_action.pointer_up(button=MouseButton.MIDDLE)
    actions.perform()

Here's the Appium log with the relevant W3C action

[HTTP] --> POST /wd/hub/session/d2b81217-19bf-4df0-95f6-2023ed335e77/element
[HTTP] {"using":"accessibility id","value":"top-cell","sessionId":"d2b81217-19bf-4df0-95f6-2023ed335e77"}
[W3C] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Matched '/wd/hub/session/d2b81217-19bf-4df0-95f6-2023ed335e77/element' to command name 'findElement'
[JSONWP Proxy] Proxying [POST /wd/hub/session/d2b81217-19bf-4df0-95f6-2023ed335e77/element] to [POST http://localhost:8080/session/93aec48e-35ae-4fb0-a3ca-5d29681cc1c6/element] with body: {"using":"accessibility id","value":"top-cell","sessionId":"d2b81217-19bf-4df0-95f6-2023ed335e77"}
[JSONWP Proxy] Got response with status 200: {"id":"a7bfe0f5-2da3-4a62-aabb-bb5c3753b8c1","sessionId":"93aec48e-35ae-4fb0-a3ca-5d29681cc1c6","status":0,"value":{"ELEMENT":"f990904f-7742-4795-b145-ec359be88d1e"}}
[JSONWP Proxy] Replacing sessionId 93aec48e-35ae-4fb0-a3ca-5d29681cc1c6 with d2b81217-19bf-4df0-95f6-2023ed335e77
[HTTP] <-- POST /wd/hub/session/d2b81217-19bf-4df0-95f6-2023ed335e77/element 200 87 ms - 166
[HTTP] 
[HTTP] --> POST /wd/hub/session/d2b81217-19bf-4df0-95f6-2023ed335e77/element
[HTTP] {"using":"accessibility id","value":"bottom-cell","sessionId":"d2b81217-19bf-4df0-95f6-2023ed335e77"}
[W3C] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Matched '/wd/hub/session/d2b81217-19bf-4df0-95f6-2023ed335e77/element' to command name 'findElement'
[JSONWP Proxy] Proxying [POST /wd/hub/session/d2b81217-19bf-4df0-95f6-2023ed335e77/element] to [POST http://localhost:8080/session/93aec48e-35ae-4fb0-a3ca-5d29681cc1c6/element] with body: {"using":"accessibility id","value":"bottom-cell","sessionId":"d2b81217-19bf-4df0-95f6-2023ed335e77"}
[JSONWP Proxy] Got response with status 200: {"id":"e728e2bc-1753-4654-a8e5-e144d5f6868f","sessionId":"93aec48e-35ae-4fb0-a3ca-5d29681cc1c6","status":0,"value":{"ELEMENT":"252c6e8f-d7f5-4a61-a1aa-79ff774776fd"}}
[JSONWP Proxy] Replacing sessionId 93aec48e-35ae-4fb0-a3ca-5d29681cc1c6 with d2b81217-19bf-4df0-95f6-2023ed335e77
[HTTP] <-- POST /wd/hub/session/d2b81217-19bf-4df0-95f6-2023ed335e77/element 200 87 ms - 166
[HTTP] 
[HTTP] --> POST /wd/hub/session/d2b81217-19bf-4df0-95f6-2023ed335e77/actions
[HTTP] {"actions":[{"type":"pointer","parameters":{"pointerType":"touch"},"id":"finger","actions":[{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"252c6e8f-d7f5-4a61-a1aa-79ff774776fd"}},{"type":"pointerDown","duration":0,"button":1},{"type":"pause","duration":1000},{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"f990904f-7742-4795-b145-ec359be88d1e"}},{"type":"pointerUp","duration":0,"button":1}]}],"sessionId":"d2b81217-19bf-4df0-95f6-2023ed335e77"}
[W3C] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Matched '/wd/hub/session/d2b81217-19bf-4df0-95f6-2023ed335e77/actions' to command name 'performActions'
[JSONWP Proxy] Proxying [POST /wd/hub/session/d2b81217-19bf-4df0-95f6-2023ed335e77/actions] to [POST http://localhost:8080/session/93aec48e-35ae-4fb0-a3ca-5d29681cc1c6/actions] with body: {"actions":[{"type":"pointer","parameters":{"pointerType":"touch"},"id":"finger","actions":[{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"252c6e8f-d7f5-4a61-a1aa-79ff774776fd"}},{"type":"pointerDown","duration":0,"button":1},{"type":"pause","duration":1000},{"type":"pointerMove","duration":250,"x":0,"y":0,"origin":{"element-6066-11e4-a52e-4f735466cecf":"f990904f-7742-4795-b145-ec359be88d1e"}},{"type":"pointerUp","duration":0,"button":1}]}],"sessionId":"d2b81217-19bf-4df0-95f6-2023ed335e77"}
[JSONWP Proxy] Got response with status 200: {"id":"28dd5e4b-fa9e-4db1-a318-377fbff4c769","sessionId":"93aec48e-35ae-4fb0-a3ca-5d29681cc1c6","status":0,"value":null}
[JSONWP Proxy] Replacing sessionId 93aec48e-35ae-4fb0-a3ca-5d29681cc1c6 with d2b81217-19bf-4df0-95f6-2023ed335e77
[HTTP] <-- POST /wd/hub/session/d2b81217-19bf-4df0-95f6-2023ed335e77/actions 200 1697 ms - 120
juandg commented 6 years ago

Pause is mandatory as WDA expects that

@saikrishna321 Thanks for clarifying that's really helpful.

juandg commented 6 years ago

@juandg is there more than one element with the id my-button?

No, the accessibility id of the button is unique for the app. my-button is a made up id I used to avoid confusion with the real name of my element.

Could the fact that this is a React Native app have anything to do with the automatic scrolling triggered by find not working? Is that functionality depending on a specific Android view type?

dpgraham commented 6 years ago

That's a relief that this is what's causing the problem. That will be easy enough to fix. The clients use mouse by default because they're Selenium clients and that's what the web uses. I'm going to put in a change that makes it use 'touch' even when it's mouse because its rare to use mouse on mobile.

React Native shouldn't make a difference. Is the element already on screen when you 'find' it? If it is, it won't scroll to that element.

juandg commented 6 years ago

@dpgraham The element is off the screen, that's why I needed this scrolling action to work so I could scroll to it and then click it. If I try to click on it while it's off the screen, I get an error, which makes sense.

The element has a unique accessibility id and I'm able to find it using different Python strategies even when it's off screen but after finding it, the UI never scrolls down to bring it into view, as you say it should do.

I'm fine with sending the W3C action chain to scroll to it in order to click it, since I need to do that for the other Appium drivers anyway, but if you think it's worth it I can open a separate issue for this behavior.

dpgraham commented 6 years ago

@juandg Actually I think the issue may be that the element is being rendered but it's not on the screen. Which the scroll-to behaviour doesn't work for. So yeah, I would just stick with using the scroll actions.

dpgraham commented 6 years ago

@juandg Actually, one more thing you can try (if you have time, of course)

After you've located the element, can you run this:

Actions action = new Actions(driver);
action.moveTo(element, 0, 0);
action.perform();
juandg commented 6 years ago

@dpgraham I tried using move to targeting the button as you suggested but I get the following error:

selenium.common.exceptions.MoveTargetOutOfBoundsException: Message: io.appium.espressoserver.lib.handlers.exceptions.MoveTargetOutOfBoundsException: The target [-737, 1547] for pointer interaction is not in the viewport and cannot be brought into that viewport
    at io.appium.espressoserver.lib.helpers.w3c.dispatcher.PointerDispatch.dispatchPointerMove(PointerDispatch.java:196)
    at io.appium.espressoserver.lib.helpers.w3c.models.ActionObject.dispatch(ActionObject.java:108)
    at io.appium.espressoserver.lib.helpers.w3c.models.Tick.dispatchAll(Tick.java:72)
    at io.appium.espressoserver.lib.helpers.w3c.models.ActionSequence.dispatch(ActionSequence.java:86)
    at io.appium.espressoserver.lib.helpers.w3c.models.Actions.perform(Actions.java:56)
    at io.appium.espressoserver.lib.handlers.PeformActions$1.run(PeformActions.java:21)
    at io.appium.espressoserver.lib.handlers.PeformActions$1.run(PeformActions.java:17)
    at io.appium.espressoserver.lib.viewaction.UiControllerPerformer.perform(UiControllerPerformer.java:43)
    at android.support.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:356)
    at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:241)
    at android.support.test.espresso.ViewInteraction.access$100(ViewInteraction.java:62)
    at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:149)
    at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:146)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)