diff --git a/appium/webdriver/extensions/location.py b/appium/webdriver/extensions/location.py index 8c469fc8..7c96f863 100644 --- a/appium/webdriver/extensions/location.py +++ b/appium/webdriver/extensions/location.py @@ -33,9 +33,9 @@ def set_location(self, latitude, longitude, altitude): """ data = { "location": { - "latitude": str(latitude), - "longitude": str(longitude), - "altitude": str(altitude) + "latitude": float(latitude), + "longitude": float(longitude), + "altitude": float(altitude) } } self.execute(Command.SET_LOCATION, data) diff --git a/test/unit/webdriver/device/location_test.py b/test/unit/webdriver/device/location_test.py index ad6a07bb..f8adb2f2 100644 --- a/test/unit/webdriver/device/location_test.py +++ b/test/unit/webdriver/device/location_test.py @@ -22,6 +22,8 @@ from appium.webdriver.webdriver import WebDriver +FLT_EPSILON = 1e-9 + class TestWebDriverLocation(object): @@ -44,9 +46,9 @@ def test_set_location(self): assert isinstance(driver.set_location(11.1, 22.2, 33.3), WebDriver) == True d = get_httpretty_request_body(httpretty.last_request()) - assert d['location']['latitude'] == '11.1' - assert d['location']['longitude'] == '22.2' - assert d['location']['altitude'] == '33.3' + assert abs(d['location']['latitude'] - 11.1) <= FLT_EPSILON + assert abs(d['location']['longitude'] - 22.2) <= FLT_EPSILON + assert abs(d['location']['altitude'] - 33.3) <= FLT_EPSILON @httpretty.activate def test_location(self): @@ -57,6 +59,6 @@ def test_location(self): body='{"value": {"latitude": 11.1, "longitude": 22.2, "altitude": 33.3}}' ) val = driver.location - assert val['latitude'] == 11.1 - assert val['longitude'] == 22.2 - assert val['altitude'] == 33.3 + assert abs(val['latitude'] - 11.1) <= FLT_EPSILON + assert abs(val['longitude'] - 22.2) <= FLT_EPSILON + assert abs(val['altitude'] - 33.3) <= FLT_EPSILON