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.

Swipe needs long value while sometimes I get float

See original GitHub issue

Given x, y in float type When I do swipe Then I will get below error

WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: 
Expected a long but was 1274.6 at line 1 column 60 path $.actions[0].options.y 	at com.google.gson.internal.bind.TypeAdapters$11.read(TypeAdapters.java:306) 	at com.google.gson.internal.bind.TypeAdapters$11.read(TypeAdapters.java:296) 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) 	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) 	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82) 	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) 	at com.google.gson.Gson.fromJson(Gson.java:922) 	at com.google.gson.Gson.fromJson(Gson.java:887) 	at com.google.gson.Gson.fromJson(Gson.java:836) 	at com.google.gson.Gson.fromJson(Gson.java:808) 	at io.appium.espressoserver.lib.http.Router.route(Router.java:263) 	at io.appium.espressoserver.lib.http.Server.serve(Server.java:65) 	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.NumberFormatException: Expected a long but was 1274.6 at line 1 column 60 path $.actions[0].options.y 	at com.google.gson.stream.JsonReader.nextLong(JsonReader.java:967) 	at com.google.gson.internal.bind.TypeAdapters$11.read(TypeAdapters.java:304) 	... 20 more
--

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
dpgrahamcommented, Nov 19, 2018

I just put in a PR… we’re going to accept floats, but round the values.

0reactions
nichotinedcommented, Nov 22, 2018

@dpgraham is this related with it?

I tried to swipe using int(500) and float(500.0) both throws an error

[W3C (e6f76aef)] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Matched '/wd/hub/session/e6f76aef-9061-4204-abf5-3009f164c7c0/touch/perform' to command name 'performTouch'
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/e6f76aef-9061-4204-abf5-3009f164c7c0/touch/perform] to [POST http://localhost:8304/session/8ac78c89-b02e-413f-b7dc-a6c924a3cca3/touch/perform] with body: {"actions":[{"action":"press","options":{"x":"540","y":"1000"}},{"action":"wait","options":{"ms":"500"}},{"action":"moveTo","options":{"x":"540","y":"700"}}],"sessionId":"e6f76aef-9061-4204-abf5-3009f164c7c0"}
[JSONWP Proxy] Got an unexpected response: {"id":"1d0be6bb-61ab-421d-b72a-b39c6df2d615","sessionId":null,"status":13,"value":"java.lang.NullPointerException: Attempt to invoke virtual method 'float java.lang.Float.floatValue()' on a null object reference\n\tat io.appium.espressoserver.lib.helpers.w3c.models.Tick.calculateTickDuration(Tick...
[debug] [W3C (e6f76aef)] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: 500 - {"id":"1d0be6bb-61ab-421d-b72a-b39c6df2d615","sessionId":null,"status":13,"value":"java.lang.NullPointerException: Attempt to invoke virtual method 'float java.lang.Float.floatValue()' on a null object reference\n\tat io.appium.espressoserver.lib.helpers.w3c.models.Tick.calculateTickDuration(Tick.java:52)\n\tat io.appium.espressoserver.lib.helpers.w3c.models.ActionSequence.dispatch(ActionSequence.java:79)\n\tat io.appium.espressoserver.lib.helpers.w3c.models.Actions.perform(Actions.java:56)\n\tat io.appium.espressoserver.lib.handlers.TouchAction$1.run(TouchAction.java:30)\n\tat io.appium.espressoserver.lib.handlers.TouchAction$1.run(TouchAction.java:22)\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:873)\n\tat android.os.Handler.dispatchMessage(Handler.java:99)\n\tat android.os.Looper.loop(Looper.java:193)\n\tat android.app.ActivityThread.main(ActivityThread.java:6669)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)\n"}
[debug] [W3C (e6f76aef)]     at /Users/nicholaslagaunne/.nvm/versions/node/v9.11.2/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:180:13
[debug] [W3C (e6f76aef)]     at Generator.throw (<anonymous>)
[debug] [W3C (e6f76aef)]     at asyncGeneratorStep (/Users/nicholaslagaunne/.nvm/versions/node/v9.11.2/lib/node_modules/appium/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
[debug] [W3C (e6f76aef)]     at _throw (/Users/nicholaslagaunne/.nvm/versions/node/v9.11.2/lib/node_modules/appium/node_modules/@babel/runtime/helpers/asyncToGenerator.js:29:9)
[debug] [W3C (e6f76aef)]     at <anonymous>
[debug] [MJSONWP] Matched JSONWP error code 13 to UnknownError
[HTTP] <-- POST /wd/hub/session/e6f76aef-9061-4204-abf5-3009f164c7c0/touch/perform 500 315 ms - 4407
[HTTP]

So I found the root cause, when I add wait, it will throws error POST http://localhost:4798/wd/hub/session/8896d495-fbd2-457e-8ef5-47172a63b495/touch/perform Body

{
  "actions": [
    { "action": "press", "options": { "x": 540, "y": 1152 } },
    { "action": "wait", "options": { "ms": 500 } },
    { "action": "moveTo", "options": { "x": 540, "y": 768 } },
    { "action": "release", "options": {} }
  ],
  "sessionId": "8896d495-fbd2-457e-8ef5-47172a63b495"
}

@dpgraham @mykola-mokhnach

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Why long literal can be assigned to float variable while ...
In this case, the resulting floating-point value will be a correctly rounded version of the integer value, using IEEE 754 round-to-nearest mode ...
Read more >
Animation | Jetpack Compose - Android Developers
If there's already an animation in flight, the animation starts from its current value (and velocity) and animates toward the target value. During...
Read more >
Why Floating-Point Numbers May Lose Precision
Floating-point decimal values generally do not have an exact binary representation. This is a side effect of how the CPU represents floating ...
Read more >
Float wants to provide liquidity to African SMBs in a way never ...
According to research, 85% of African SMBs have zero access to financing, and each day, African SMBs have billions locked up in receivables ......
Read more >
Use the floating keyboard on your iPad - Apple Support
Then you can change the keyboard back to its full size. How to make your iPad keyboard smaller. Open an app that uses...
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