diff --git a/appium/webdriver/extensions/location.py b/appium/webdriver/extensions/location.py index 780db790a..68d451a61 100644 --- a/appium/webdriver/extensions/location.py +++ b/appium/webdriver/extensions/location.py @@ -43,6 +43,7 @@ def set_location( longitude: Union[float, str], altitude: Union[float, str] = None, speed: Union[float, str] = None, + satellites: Union[float, str] = None, ) -> T: """Set the location of the device @@ -51,6 +52,7 @@ def set_location( longitude: String or numeric value between -180.0 and 180.0 altitude: String or numeric value (Android real device only) speed: String or numeric value larger than 0.0 (Android real devices only) + satellites: String or numeric value of active GPS satellites in range 1..12. (Android emulators only) Returns: Union['WebDriver', 'Location']: Self instance @@ -65,6 +67,8 @@ def set_location( data['location']['altitude'] = altitude if speed is not None: data['location']['speed'] = speed + if satellites is not None: + data['location']['satellites'] = satellites self.execute(Command.SET_LOCATION, data) return self diff --git a/test/unit/webdriver/device/location_test.py b/test/unit/webdriver/device/location_test.py index afbef3329..c351c2f4f 100644 --- a/test/unit/webdriver/device/location_test.py +++ b/test/unit/webdriver/device/location_test.py @@ -33,25 +33,27 @@ def test_toggle_location_services(self): def test_set_location_float(self): driver = android_w3c_driver() httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/location')) - assert isinstance(driver.set_location(11.1, 22.2, 33.3, 23.2), WebDriver) + assert isinstance(driver.set_location(11.1, 22.2, 33.3, 23.2, 12), WebDriver) d = get_httpretty_request_body(httpretty.last_request()) 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 assert abs(d['location']['speed'] - 23.2) <= FLT_EPSILON + assert abs(d['location']['satellites'] - 12) <= FLT_EPSILON @httpretty.activate def test_set_location_str(self): driver = android_w3c_driver() httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/location')) - assert isinstance(driver.set_location('11.1', '22.2', '33.3', '23.2'), WebDriver) + assert isinstance(driver.set_location('11.1', '22.2', '33.3', '23.2', '12'), WebDriver) 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 d['location']['speed'] == '23.2' + assert d['location']['satellites'] == '12' @httpretty.activate def test_set_location_without_altitude(self):