Skip to content

setLocation with "io.appium.java_client.Location" throws "Error: longitude must be provided" #2108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Jan 30, 2024 · 0 comments · Fixed by #2109
Closed

Comments

@ghost
Copy link

ghost commented Jan 30, 2024

Description

Failed to setLocation with "io.appium.java_client.Location"

Environment

  • Java client build version or git revision if you use some snapshot: 9.1.0
  • Appium server version or git revision if you use some snapshot: 2.4.1
  • Desktop OS/version used to run Appium if necessary: MAC OS
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: 18.19.0
  • Mobile platform/version under test: android
  • Real device or emulator/simulator: emulator

Details

The issue might be from "SupportsLocation"

default void setLocation(io.appium.java_client.Location location) {
        ImmutableMap.Builder<String, Object> locationParameters = ImmutableMap.builder();
        locationParameters.put("latitude", location.getLatitude());
        locationParameters.put("longitude", location.getLongitude());
        Optional.ofNullable(location.getAltitude()).ifPresent(altitude -> locationParameters.put("altitude", altitude));
        execute(MobileCommand.SET_LOCATION, Map.of("location", locationParameters));
    }

Should it be "locationParameters.build()" instead of "locationParameters" in execute method call?

Appium Server Log

 --> POST /wd/hub/session/18706d75-ea01-4f72-b15e-3861c384e47d/location
[HTTP] {"location":{"class":"com.google.common.collect.ImmutableMap$Builder"}}
[AndroidUiautomator2Driver@b8a0 (18706d75)] Calling AppiumDriver.setGeoLocation() with args: [{"class":"com.google.common.collect.ImmutableMap$Builder"},"18706d75-ea01-4f72-b15e-3861c384e47d"]
[AndroidUiautomator2Driver@b8a0 (18706d75)] Encountered internal error running command: Error: longitude must be provided
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at formatLocationValue (/Users/rachun/.appium/node_modules/appium-uiautomator2-driver/node_modules/io.appium.settings/lib/commands/geolocation.js:46:15)
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at SettingsApp.setGeoLocation (/Users/rachun/.appium/node_modules/appium-uiautomator2-driver/node_modules/io.appium.settings/lib/commands/geolocation.js:60:44)
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at AndroidUiautomator2Driver.setGeoLocation (/Users/rachun/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/geolocation.js:22:26)
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at commandExecutor (/Users/rachun/.nvm/versions/node/v18.19.0/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/driver.ts:106:18)
[AndroidUiautomator2Driver@b8a0 (18706d75)] From previous event:
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at commandExecutor (/Users/rachun/.nvm/versions/node/v18.19.0/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/driver.ts:105:15)
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at /Users/rachun/.nvm/versions/node/v18.19.0/lib/node_modules/appium/node_modules/async-lock/lib/index.js:171:12
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at AsyncLock._promiseTry (/Users/rachun/.nvm/versions/node/v18.19.0/lib/node_modules/appium/node_modules/async-lock/lib/index.js:306:31)
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at exec (/Users/rachun/.nvm/versions/node/v18.19.0/lib/node_modules/appium/node_modules/async-lock/lib/index.js:170:9)
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at AsyncLock.acquire (/Users/rachun/.nvm/versions/node/v18.19.0/lib/node_modules/appium/node_modules/async-lock/lib/index.js:189:3)
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at AndroidUiautomator2Driver.executeCommand (/Users/rachun/.nvm/versions/node/v18.19.0/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/driver.ts:122:39)
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at processTicksAndRejections (node:internal/process/task_queues:95:5)
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at defaultBehavior (/Users/rachun/.nvm/versions/node/v18.19.0/lib/node_modules/appium/lib/appium.js:1109:14)
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at AppiumDriver.executeWrappedCommand (/Users/rachun/.nvm/versions/node/v18.19.0/lib/node_modules/appium/lib/appium.js:1215:16)
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at AppiumDriver.executeCommand (/Users/rachun/.nvm/versions/node/v18.19.0/lib/node_modules/appium/lib/appium.js:1121:17)
[AndroidUiautomator2Driver@b8a0 (18706d75)]     at asyncHandler (/Users/rachun/.nvm/versions/node/v18.19.0/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/protocol.js:393:19)
[HTTP] <-- POST /wd/hub/session/18706d75-ea01-4f72-b15e-3861c384e47d/location 500 8 ms - 614

Code To Reproduce Issue [ Good To Have ]

((SupportsLocation) driver).setLocation(new Location(42.999141, -78.8210775));

Exception Stacktraces

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: longitude must be provided
Build info: version: '4.17.0', revision: 'e52b1be057*'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '14.2.1', java.version: '17.0.5'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [18706d75-ea01-4f72-b15e-3861c384e47d, setLocation {location=com.google.common.collect.ImmutableMap$Builder@5e610ed7}]

	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:134)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:51)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:190)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:237)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:519)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:592)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:302)
	at io.appium.java_client.remote.SupportsLocation.setLocation(SupportsLocation.java:93)

Link To Appium Logs

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

0 participants