I tried these suggestions but they still did not resolve issue with W3C Long Tap
- Disable animations via UiAutomator2 appium:disableWindowAnimation
- Disable BrowserStack device animations
- Adding a wait of 10 seconds before subsequent long tap
Here are the Appium Server Logs:
2024-07-30 10:09:32:295 - [HTTP] --> POST /wd/hub/session/c0d2eab5-637b-44b1-90bd-f6aef3e21846/actions
2024-07-30 10:09:32:295 - [HTTP] {"actions":[{"id":"finger1","type":"pointer","parameters":{"pointerType":"touch"},"actions":[{"duration":0,"type":"pause"},{"duration":0,"x":521,"y":1791,"type":"pointerMove","origin":"viewport"},{"button":0,"type":"pointerDown"},{"duration":5000,"type":"pause"},{"button":0,"type":"pointerUp"}]}]}
2024-07-30 10:09:32:295 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] Calling AppiumDriver.performActions() with args: [[{"id":"finger1","type":"pointer","parameters":{"pointerType":"touch"},"actions":[{"duration":0,"type":"pause"},{"duration":0,"x":521,"y":1791,"type":"pointerMove","origin":"viewport"},{"button":0,"type":"pointerDown"},{"duration":5000,"type":"pause"},{"button":0,"type":"pointerUp"}]}],"c0d2eab5-637b-44b1-90bd-f6aef3e21846"]
2024-07-30 10:09:32:296 - [AppiumDriver@15dc] Clearing new command timeout pre-emptively since plugin(s) will handle this command
2024-07-30 10:09:32:296 - [AppiumDriver@15dc] Plugins which can handle cmd 'performActions': images
2024-07-30 10:09:32:296 - [AppiumDriver@15dc] Plugin images is now handling cmd 'performActions'
2024-07-30 10:09:32:296 - [AppiumDriver@15dc] Executing default handling behavior for command 'performActions'
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] Received the following W3C actions: [
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] {
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "id": "finger1",
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "type": "pointer",
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "parameters": {
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "pointerType": "touch"
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] },
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "actions": [
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] {
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "duration": 0,
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "type": "pause"
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] },
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] {
2024-07-30 10:09:32:296 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "duration": 0,
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "x": 521,
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "y": 1791,
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "type": "pointerMove",
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "origin": "viewport"
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] },
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] {
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "button": 0,
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "type": "pointerDown"
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] },
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] {
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "duration": 5000,
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "type": "pause"
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] },
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] {
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "button": 0,
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "type": "pointerUp"
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] }
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] ]
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] }
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] ]
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] Preprocessed actions: [
2024-07-30 10:09:32:297 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] {
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "id": "finger1",
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "type": "pointer",
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "parameters": {
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "pointerType": "touch"
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] },
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "actions": [
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] {
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "duration": 0,
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "type": "pause"
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] },
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] {
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "duration": 0,
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "x": 521,
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "y": 1791,
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "type": "pointerMove",
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "origin": "viewport"
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] },
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] {
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "button": 0,
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "type": "pointerDown"
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] },
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] {
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "duration": 5000,
2024-07-30 10:09:32:298 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "type": "pause"
2024-07-30 10:09:32:299 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] },
2024-07-30 10:09:32:299 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] {
2024-07-30 10:09:32:299 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "button": 0,
2024-07-30 10:09:32:299 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] "type": "pointerUp"
2024-07-30 10:09:32:299 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] }
2024-07-30 10:09:32:299 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] ]
2024-07-30 10:09:32:299 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] }
2024-07-30 10:09:32:299 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] ]
2024-07-30 10:09:32:299 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] Matched '/actions' to command name 'performActions'
2024-07-30 10:09:32:300 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] Proxying [POST /actions] to [POST http://127.0.0.1:8203/session/3af37a41-ab24-4bc9-85b6-05a5a4649755/actions] with body: {"actions":[{"id":"finger1","type":"pointer","parameters":{"pointerType":"touch"},"actions":[{"duration":0,"type":"pause"},{"duration":0,"x":521,"y":1791,"type":"pointerMove","origin":"viewport"},{"button":0,"type":"pointerDown"},{"duration":5000,"type":"pause"},{"button":0,"type":"pointerUp"}]}]}
2024-07-30 10:09:37:353 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] Got response with status 400: {"sessionId":"3af37a41-ab24-4bc9-85b6-05a5a4649755","value":{"error":"invalid element state","message":"Unable to perform W3C actions. Check the logcat output for possible error reports and make sure your input actions chain is valid.","stacktrace":"io.appium.uiautomator2.common.exceptions.InvalidElementStateException: Unable to perform W3C actions. Check the logcat output for possible error reports and make sure your input actions chain is valid.\n\tat io.appium.uiautomator2.handler.W3CActions.safeHandle(W3CActions.java:82)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:59)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:277)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:271)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:77)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.ch...
2024-07-30 10:09:37:353 - [W3C] Matched W3C error code 'invalid element state' to InvalidElementStateError
2024-07-30 10:09:37:360 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] Encountered internal error running command: io.appium.uiautomator2.common.exceptions.InvalidElementStateException: Unable to perform W3C actions. Check the logcat output for possible error reports and make sure your input actions chain is valid.
2024-07-30 10:09:37:360 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.appium.uiautomator2.handler.W3CActions.safeHandle(W3CActions.java:82)
2024-07-30 10:09:37:360 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:59)
2024-07-30 10:09:37:360 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:277)
2024-07-30 10:09:37:360 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:271)
2024-07-30 10:09:37:360 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:77)
2024-07-30 10:09:37:360 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
2024-07-30 10:09:37:360 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
2024-07-30 10:09:37:361 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)
2024-07-30 10:09:37:362 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:552)
2024-07-30 10:09:37:362 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:466)
2024-07-30 10:09:37:362 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
2024-07-30 10:09:37:362 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
2024-07-30 10:09:37:362 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
2024-07-30 10:09:37:362 - [AndroidUiautomator2Driver@1186 (c0d2eab5)] at java.lang.Thread.run(Thread.java:1012)
2024-07-30 10:09:37:362 - [AndroidUiautomator2Driver@1186 (c0d2eab5)]
2024-07-30 10:09:37:362 - [HTTP] <-- POST /wd/hub/session/c0d2eab5-637b-44b1-90bd-f6aef3e21846/actions 400 5067 ms - 3891
2024-07-30 10:09:37:362 - [HTTP]
My obvious guess is something wrong with BrowserStack, as same code works fine locally as well as on emulator.
What I do not understand is how the long tap gesture from UiAutomator2 works differently to not get the same error?
Below are the Appium Server logs from longClick gesture performed via UiAutomator2:
2024-07-30 10:06:04:936 - [HTTP] --> POST /wd/hub/session/97514d43-9cbd-448d-9b75-026b08fe8a9c/execute/sync
2024-07-30 10:06:04:936 - [HTTP] {"script":"mobile: longClickGesture","args":[{"elementId":"00000000-0000-085b-0000-006d00000115","duration":5000,"x":0,"y":0}]}
2024-07-30 10:06:04:936 - [AndroidUiautomator2Driver@1bb6 (97514d43)] Calling AppiumDriver.execute() with args: ["mobile: longClickGesture",[{"elementId":"00000000-0000-085b-0000-006d00000115","duration":5000,"x":0,"y":0}],"97514d43-9cbd-448d-9b75-026b08fe8a9c"]
2024-07-30 10:06:04:936 - [AppiumDriver@6237] Clearing new command timeout pre-emptively since plugin(s) will handle this command
2024-07-30 10:06:04:936 - [AppiumDriver@6237] Plugins which can handle cmd 'execute': images
2024-07-30 10:06:04:936 - [AppiumDriver@6237] Plugin images is now handling cmd 'execute'
2024-07-30 10:06:04:937 - [AppiumDriver@6237] Executing default handling behavior for command 'execute'
2024-07-30 10:06:04:937 - [AndroidUiautomator2Driver@1bb6 (97514d43)] Executing method 'mobile: longClickGesture'
2024-07-30 10:06:04:943 - [AndroidUiautomator2Driver@1bb6 (97514d43)] Proxying [POST /appium/gestures/long_click] to [POST http://127.0.0.1:8204/session/88b4febd-5ee0-417d-b1f7-e25a2a53b14f/appium/gestures/long_click] with body: {"origin":{"ELEMENT":"00000000-0000-085b-0000-006d00000115","element-6066-11e4-a52e-4f735466cecf":"00000000-0000-085b-0000-006d00000115"},"offset":{"x":0,"y":0},"duration":5000}
2024-07-30 10:06:10:815 - [AndroidUiautomator2Driver@1bb6 (97514d43)] Got response with status 200: {"sessionId":"88b4febd-5ee0-417d-b1f7-e25a2a53b14f","value":null}
2024-07-30 10:06:10:816 - [AndroidUiautomator2Driver@1bb6 (97514d43)] Responding to client with driver.execute() result: null
2024-07-30 10:06:10:816 - [HTTP] <-- POST /wd/hub/session/97514d43-9cbd-448d-9b75-026b08fe8a9c/execute/sync 200 5880 ms - 14