question-mark
Stuck on an issue?

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

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

Unable to scroll/swipe

See original GitHub issue

I started to use Appium: 1.9.0 with appium-espresso-driver for the testing with webdriver. However, I cannot get scrolling/swiping working.

I tried below:

browser.touchDown(10, 900);
browser.touchMove(10, 10);
browser.touchUp(10,10);

It doesn’t give any error, but it doesn’t do anything on the page (the same happens if I use “browser.touchPerform” or “browser.touchAction”).

browser.performTouchAction([{ action: 'press', options: { x: 1945, y: 1255 } }]); browser.performTouchAction([{ action: 'moveTo', options: { x: 66, y: 470 } }]); browser.performTouchAction([{ action: 'release', options: {} }]); Gives the following error:

An unknown server-side error occurred while processing the command. Original error: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $ at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224) at com.google.gson.Gson.fromJson(Gson.java:888) at com.google.gson.Gson.fromJson(Gson.java:853) at com.google.gson.Gson.fromJson(Gson.java:802) at com.google.gson.Gson.fromJson(Gson.java:774) at io.appium.espressoserver.lib.http.Router.route(Router.java:240) at io.appium.espressoserver.lib.http.Server.serve(Server.java:62) at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244) at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945) at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192) at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $ at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:213) … 10 more

Using browser.scroll(element_selector, 50, 900); gives me the following error:

An unknown server-side error occurred while processing the command. Original error: java.lang.NullPointerException: Attempt to invoke virtual method ‘long java.lang.Long.longValue()’ on a null object reference at io.appium.espressoserver.lib.handlers.PointerEventHandler.handleTouchScroll(PointerEventHandler.java:217) at io.appium.espressoserver.lib.handlers.PointerEventHandler.handle(PointerEventHandler.java:92) at io.appium.espressoserver.lib.handlers.PointerEventHandler.handle(PointerEventHandler.java:35) at io.appium.espressoserver.lib.http.Router.route(Router.java:251) at io.appium.espressoserver.lib.http.Server.serve(Server.java:62) at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244) at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945) at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192) at java.lang.Thread.run(Thread.java:764)

I tried few more methods to scroll vertically or swipe horizontally but pretty much all of them give me one of the above results. I would like to use this driver for our testing as it gives us an easy way to access elements. However, I need to have the scrolling.swiping functionality and I cannot get it working. Is there a way to do it with the current version of the driver?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ania-scommented, Sep 21, 2018

Please find below the appium logs for the following commands. If you need some more logs for any particular commands please let me know:

browser.performTouchAction([{ action: 'press', options: { x: 1945, y: 1255 } }]);

[info] [JSONWP Proxy] Replacing sessionId 24d3fe1b-e5ed-4633-bf4b-b854518ab1ff with f7927255-d9e6-44c5-902a-0519692ecad3 [info] [HTTP] <-- POST /wd/hub/session/f7927255-d9e6-44c5-902a-0519692ecad3/element 200 188 ms - 166 [info] [HTTP] [info] [HTTP] --> GET /wd/hub/session/f7927255-d9e6-44c5-902a-0519692ecad3/element/a4ad3386-f931-4cd8-bf71-745813d087b4/size [info] [HTTP] {} [info] [MJSONWP] Driver proxy active, passing request on via HTTP proxy [debug] [JSONWP Proxy] Matched ‘/wd/hub/session/f7927255-d9e6-44c5-902a-0519692ecad3/element/a4ad3386-f931-4cd8-bf71-745813d087b4/size’ to command name ‘getSize’ [debug] [JSONWP Proxy] Proxying [GET /wd/hub/session/f7927255-d9e6-44c5-902a-0519692ecad3/element/a4ad3386-f931-4cd8-bf71-745813d087b4/size] to [GET http://localhost:8080/session/24d3fe1b-e5ed-4633-bf4b-b854518ab1ff/element/a4ad3386-f931-4cd8-bf71-745813d087b4/size] with body: {} [debug] [JSONWP Proxy] Got response with status 200: “{"id":"2babdeec-1392-4113-b65f-be4a598ee615","sessionId":"24d3fe1b-e5ed-4633-bf4b-b854518ab1ff","status":0,"value":{"height":49,"width":172,"uriParams":{}}}” [info] [JSONWP Proxy] Replacing sessionId 24d3fe1b-e5ed-4633-bf4b-b854518ab1ff with f7927255-d9e6-44c5-902a-0519692ecad3 [info] [HTTP] <-- GET /wd/hub/session/f7927255-d9e6-44c5-902a-0519692ecad3/element/a4ad3386-f931-4cd8-bf71-745813d087b4/size 200 52 ms - 156 [info] [HTTP] [info] [HTTP] --> POST /wd/hub/session/f7927255-d9e6-44c5-902a-0519692ecad3/touch/perform [info] [HTTP] [{“action”:“press”,“options”:{“x”:1945,“y”:1255}}] [info] [MJSONWP] Driver proxy active, passing request on via HTTP proxy [debug] [JSONWP Proxy] Matched ‘/wd/hub/session/f7927255-d9e6-44c5-902a-0519692ecad3/touch/perform’ to command name ‘performTouch’ [debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/f7927255-d9e6-44c5-902a-0519692ecad3/touch/perform] to [POST http://localhost:8080/session/24d3fe1b-e5ed-4633-bf4b-b854518ab1ff/touch/perform] with body: [{“action”:“press”,“options”:{“x”:1945,“y”:1255}}][error] [MJSONWP] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: 500 - {“id”:“e46d2bf0-7ad9-4f6e-99f9-02a2e314b267”,“sessionId”:null,“status”:13,“value”:“com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $\n\tat com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224)\n\tat com.google.gson.Gson.fromJson(Gson.java:888)\n\tat com.google.gson.Gson.fromJson(Gson.java:853)\n\tat com.google.gson.Gson.fromJson(Gson.java:802)\n\tat com.google.gson.Gson.fromJson(Gson.java:774)\n\tat io.appium.espressoserver.lib.http.Router.route(Router.java:240)\n\tat io.appium.espressoserver.lib.http.Server.serve(Server.java:62)\n\tat fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)\n\tat fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)\n\tat fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)\n\tat java.lang.Thread.run(Thread.java:764)\nCaused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $\n\tat com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385)\n\tat com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:213)\n\t… 10 more\n”} [error] [MJSONWP] at JWProxy.proxy$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:194:13) [error] [MJSONWP] at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) [error] [MJSONWP] at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) [error] [MJSONWP] at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js💯21) [error] [MJSONWP] at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) [error] [MJSONWP] at <anonymous> [debug] [MJSONWP] Matched JSONWP error code 13 to UnknownError [info] [HTTP] <-- POST /wd/hub/session/f7927255-d9e6-44c5-902a-0519692ecad3/touch/perform 500 71 ms - 1327

browser.touchDown(1945, 1255);
   browser.touchMove(66, 470);
   browser.touchUp(66,470);

[info] [HTTP] --> POST /wd/hub/session/66c4fe58-b7c2-428c-8c2f-cc8ea844891d/touch/down [info] [HTTP] {“x”:1945,“y”:1255} [info] [MJSONWP] Driver proxy active, passing request on via HTTP proxy [debug] [JSONWP Proxy] Matched ‘/wd/hub/session/66c4fe58-b7c2-428c-8c2f-cc8ea844891d/touch/down’ to command name ‘touchDown’ [debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/66c4fe58-b7c2-428c-8c2f-cc8ea844891d/touch/down] to [POST http://localhost:8080/session/a6c5edc6-bea7-49eb-88fd-90232c848fe6/touch/down] with body: {“x”:1945,“y”:1255}[debug] [JSONWP Proxy] Got response with status 200: {“id”:“afbaa52e-a94e-4dba-b882-2c9a81c0425f”,“sessionId”:“a6c5edc6-bea7-49eb-88fd-90232c848fe6”,“status”:0,“value”:null} [info] [JSONWP Proxy] Replacing sessionId a6c5edc6-bea7-49eb-88fd-90232c848fe6 with 66c4fe58-b7c2-428c-8c2f-cc8ea844891d [info] [HTTP] <-- POST /wd/hub/session/66c4fe58-b7c2-428c-8c2f-cc8ea844891d/touch/down 200 447 ms - 120 [info] [HTTP] [info] [HTTP] --> POST /wd/hub/session/66c4fe58-b7c2-428c-8c2f-cc8ea844891d/touch/move [info] [HTTP] {“x”:66,“y”:470} [info] [MJSONWP] Driver proxy active, passing request on via HTTP proxy [debug] [JSONWP Proxy] Matched ‘/wd/hub/session/66c4fe58-b7c2-428c-8c2f-cc8ea844891d/touch/move’ to command name ‘touchMove’ [debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/66c4fe58-b7c2-428c-8c2f-cc8ea844891d/touch/move] to [POST http://localhost:8080/session/a6c5edc6-bea7-49eb-88fd-90232c848fe6/touch/move] with body: {“x”:66,“y”:470} [debug] [JSONWP Proxy] Got response with status 200: {“id”:“e2c551de-b99b-466f-bc5a-921ce5e7830e”,“sessionId”:“a6c5edc6-bea7-49eb-88fd-90232c848fe6”,“status”:0,“value”:null} [info] [JSONWP Proxy] Replacing sessionId a6c5edc6-bea7-49eb-88fd-90232c848fe6 with 66c4fe58-b7c2-428c-8c2f-cc8ea844891d [info] [HTTP] <-- POST /wd/hub/session/66c4fe58-b7c2-428c-8c2f-cc8ea844891d/touch/move 200 82 ms - 120 [info] [HTTP] [info] [HTTP] --> POST /wd/hub/session/66c4fe58-b7c2-428c-8c2f-cc8ea844891d/touch/up [info] [HTTP] {“x”:66,“y”:470} [info] [MJSONWP] Driver proxy active, passing request on via HTTP proxy [debug] [JSONWP Proxy] Matched ‘/wd/hub/session/66c4fe58-b7c2-428c-8c2f-cc8ea844891d/touch/up’ to command name ‘touchUp’ [debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/66c4fe58-b7c2-428c-8c2f-cc8ea844891d/touch/up] to [POST http://localhost:8080/session/a6c5edc6-bea7-49eb-88fd-90232c848fe6/touch/up] with body: {“x”:66,“y”:470}[debug] [JSONWP Proxy] Got response with status 200: {“id”:“f664cf80-82cf-426b-8b6e-f9a20ad20608”,“sessionId”:“a6c5edc6-bea7-49eb-88fd-90232c848fe6”,“status”:0,“value”:null} [info] [JSONWP Proxy] Replacing sessionId a6c5edc6-bea7-49eb-88fd-90232c848fe6 with 66c4fe58-b7c2-428c-8c2f-cc8ea844891d [info] [HTTP] <-- POST /wd/hub/session/66c4fe58-b7c2-428c-8c2f-cc8ea844891d/touch/up 200 98 ms - 120

browser.scroll(element_selector, 50, 900);

[info] [HTTP] [info] [HTTP] --> POST /wd/hub/session/14f24043-b640-4d58-8993-33ff8b02b89f/element [info] [HTTP] {“using”:“xpath”,“value”:“//[@view-tag=‘TermsAndConditionsCard_testId’]“} [info] [MJSONWP] Driver proxy active, passing request on via HTTP proxy [debug] [JSONWP Proxy] Matched ‘/wd/hub/session/14f24043-b640-4d58-8993-33ff8b02b89f/element’ to command name ‘findElement’ [debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/14f24043-b640-4d58-8993-33ff8b02b89f/element] to [POST http://localhost:8080/session/afe598d4-aba1-4640-b47d-74e5f2511315/element] with body: {“using”:“xpath”,“value”:”//[@view-tag=‘TermsAndConditionsCard_testId’]”}[debug] [JSONWP Proxy] Got response with status 200: {“id”:“22fbb34d-5754-441d-89c2-0d7694a5d21c”,“sessionId”:“afe598d4-aba1-4640-b47d-74e5f2511315”,“status”:0,“value”:{“ELEMENT”:“bbd847e5-f934-4ff5-b79d-ec96eb4d70cc”}} [info] [JSONWP Proxy] Replacing sessionId afe598d4-aba1-4640-b47d-74e5f2511315 with 14f24043-b640-4d58-8993-33ff8b02b89f [info] [HTTP] <-- POST /wd/hub/session/14f24043-b640-4d58-8993-33ff8b02b89f/element 200 315 ms - 166 [info] [HTTP] [info] [HTTP] --> POST /wd/hub/session/14f24043-b640-4d58-8993-33ff8b02b89f/touch/scroll [info] [HTTP] {“element”:“bbd847e5-f934-4ff5-b79d-ec96eb4d70cc”,“xoffset”:50,“yoffset”:900} [info] [MJSONWP] Driver proxy active, passing request on via HTTP proxy [debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/14f24043-b640-4d58-8993-33ff8b02b89f/touch/scroll] to [POST http://localhost:8080/session/afe598d4-aba1-4640-b47d-74e5f2511315/touch/scroll] with body: {“element”:“bbd847e5-f934-4ff5-b79d-ec96eb4d70cc”,“xoffset”:50,“yoffset”:900}[error] [MJSONWP] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: 500 - {“id”:“d28cdd43-e7fc-48c7-9bf4-a46c72b3320a”,“sessionId”:null,“status”:13,“value”:“java.lang.NullPointerException: Attempt to invoke virtual method ‘long java.lang.Long.longValue()’ on a null object reference\n\tat io.appium.espressoserver.lib.handlers.PointerEventHandler.handleTouchScroll(PointerEventHandler.java:217)\n\tat io.appium.espressoserver.lib.handlers.PointerEventHandler.handle(PointerEventHandler.java:92)\n\tat io.appium.espressoserver.lib.handlers.PointerEventHandler.handle(PointerEventHandler.java:35)\n\tat io.appium.espressoserver.lib.http.Router.route(Router.java:251)\n\tat io.appium.espressoserver.lib.http.Server.serve(Server.java:62)\n\tat fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)\n\tat fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)\n\tat fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)\n\tat java.lang.Thread.run(Thread.java:764)\n”} [error] [MJSONWP] at JWProxy.proxy$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:194:13) [error] [MJSONWP] at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) [error] [MJSONWP] at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) [error] [MJSONWP] at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js💯21) [error] [MJSONWP] at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) [error] [MJSONWP] at <anonymous> [debug] [MJSONWP] Matched JSONWP error code 13 to UnknownError [info] [HTTP] <-- POST /wd/hub/session/14f24043-b640-4d58-8993-33ff8b02b89f/touch/scroll 500 77 ms - 988

1reaction
dpgrahamcommented, Oct 31, 2018

So, I’m pretty sure the issue with this:

browser.performTouchAction([{ action: 'press', options: { x: 1945, y: 1255 } }]);
browser.performTouchAction([{ action: 'moveTo', options: { x: 66, y: 470 } }]);
browser.performTouchAction([{ action: 'release', options: {} }]);

Is that they shouldn’t be arrays, but individual objects.

As for the first one:

browser.touchDown(10, 900);
browser.touchMove(10, 10);
browser.touchUp(10,10);

This should be fixed with the latest version (try installing npm uninstall -g appium && npm install -g appium@beta). It was using mouse pointer by default before, now it uses touch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Two Finger Scroll Not Working Windows 10 (Fixed)
Choose Touchpad from the menu in the left side pane. Locate the Scroll and zoom section. Here, make sure that the box next...
Read more >
[iOS][15.6.1] unable to scroll or swipe right on pictures - Reddit
When you swipe, you can use a broad gesture. With this new gallery, you have to click a tiny sliver of the screen...
Read more >
My swipe gesture is not working. I can't scroll just by swiping
My swipe gesture is not working. I can't scroll just by swiping the mouse pad. · Press Windows key, click on Settings. ·...
Read more >
Answered: Re: can't swipe and scroll - Google Nest Community
I can no longer scroll and swipe on the nest hub. be told last, first or default. Must activate first, then double click....
Read more >
Unable to scroll using swipe() in Appium - java - Stack Overflow
I am unable to scroll down in Android using Appium. Code: driver.swipe(0, 0, 450, 250, 2000);.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

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

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found