Skip to content

Loading…

Clients can set any coordinates for the simulated location. #274

Merged
merged 1 commit into from

2 participants

@iamleeg

The method previously ignored client input and hard-coded the location. Now it uses the "latitude" and "longitude" keys in the request payload.

@mmmulani mmmulani merged commit 96e1d99 into ios-driver:dev

1 check failed

Details continuous-integration/travis-ci The Travis CI build could not complete due to an error
@iamleeg iamleeg deleted the iamleeg:set_simulated_location branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
12 server/src/main/java/org/uiautomation/ios/command/uiautomation/SetLocationNHandler.java
@@ -16,6 +16,7 @@
import org.json.JSONException;
import org.json.JSONObject;
+import org.openqa.selenium.WebDriverException;
import org.uiautomation.ios.communication.WebDriverLikeRequest;
import org.uiautomation.ios.IOSServerManager;
import org.uiautomation.ios.command.UIAScriptHandler;
@@ -31,9 +32,18 @@
public SetLocationNHandler(IOSServerManager driver, WebDriverLikeRequest request) {
super(driver, request);
JSONObject payload = request.getPayload();
+ String latitude;
+ String longitude;
+ try {
+ latitude = String.valueOf(payload.getDouble("latitude"));
+ longitude = String.valueOf(payload.getDouble("longitude"));
+ }
+ catch (JSONException e) {
+ throw new WebDriverException("error parsing request " + request + "\n" + e.getMessage(), e);
+ }
String js = template.generate(
request.getSession(),
- "{'latitude': 45 ,'longitude': 45 }");
+ "{'latitude': " + latitude + " ,'longitude': " + longitude + " }");
setJS(js);
}
Something went wrong with that request. Please try again.