Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Appium.Net/Appium/AppiumDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,17 @@ public Location Location
{
var commandResponse = ((IExecuteMethod)this).Execute(AppiumDriverCommand.GetLocation);
var locationValues = commandResponse.Value as Dictionary<string, object>;

if (locationValues == null)
{
return new Location();
}

return new Location
{
Altitude = Convert.ToDouble(locationValues["altitude"]),
Latitude = Convert.ToDouble(locationValues["latitude"]),
Longitude = Convert.ToDouble(locationValues["longitude"])
Altitude = locationValues.TryGetValue("altitude", out var alt) ? Convert.ToDouble(alt) : 0.0,
Latitude = locationValues.TryGetValue("latitude", out var lat) ? Convert.ToDouble(lat) : 0.0,
Longitude = locationValues.TryGetValue("longitude", out var lon) ? Convert.ToDouble(lon) : 0.0
};
}
set
Expand Down
4 changes: 2 additions & 2 deletions test/integration/Android/ActionsChainsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ public void TouchByCoordinatesTestCase()

Point point = new()
{
X = (elementToTouch.Rect.X+elementToTouch.Rect.Width)/2,
Y = elementToTouch.Rect.Y
X = (elementToTouch.Location.X+elementToTouch.Size.Width)/2,
Y = elementToTouch.Location.Y
};

Interaction move = touch.CreatePointerMove(CoordinateOrigin.Viewport, point.X, point.Y, TimeSpan.Zero);
Expand Down
Loading