Sitelet https://github.com/appium/python-client/commit/cfb6ee6487217d0b01c42b2b9d291779ea17dd85
Skip to content

Commit cfb6ee6

Browse files
authored
feat: add satellites in set_location (#620)
* feat: add satellites in set_location * fix review
1 parent bc9eb18 commit cfb6ee6

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎appium/webdriver/extensions/location.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def set_location(
4343
longitude: Union[float, str],
4444
altitude: Union[float, str] = None,
4545
speed: Union[float, str] = None,
46+
satellites: Union[float, str] = None,
4647
) -> T:
4748
"""Set the location of the device
4849
@@ -51,6 +52,7 @@ def set_location(
5152
longitude: String or numeric value between -180.0 and 180.0
5253
altitude: String or numeric value (Android real device only)
5354
speed: String or numeric value larger than 0.0 (Android real devices only)
55+
satellites: String or numeric value of active GPS satellites in range 1..12. (Android emulators only)
5456
5557
Returns:
5658
Union['WebDriver', 'Location']: Self instance
@@ -65,6 +67,8 @@ def set_location(
6567
data['location']['altitude'] = altitude
6668
if speed is not None:
6769
data['location']['speed'] = speed
70+
if satellites is not None:
71+
data['location']['satellites'] = satellites
6872
self.execute(Command.SET_LOCATION, data)
6973
return self
7074

‎test/unit/webdriver/device/location_test.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,27 @@ def test_toggle_location_services(self):
3333
def test_set_location_float(self):
3434
driver = android_w3c_driver()
3535
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/location'))
36-
assert isinstance(driver.set_location(11.1, 22.2, 33.3, 23.2), WebDriver)
36+
assert isinstance(driver.set_location(11.1, 22.2, 33.3, 23.2, 12), WebDriver)
3737

3838
d = get_httpretty_request_body(httpretty.last_request())
3939
assert abs(d['location']['latitude'] - 11.1) <= FLT_EPSILON
4040
assert abs(d['location']['longitude'] - 22.2) <= FLT_EPSILON
4141
assert abs(d['location']['altitude'] - 33.3) <= FLT_EPSILON
4242
assert abs(d['location']['speed'] - 23.2) <= FLT_EPSILON
43+
assert abs(d['location']['satellites'] - 12) <= FLT_EPSILON
4344

4445
@httpretty.activate
4546
def test_set_location_str(self):
4647
driver = android_w3c_driver()
4748
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/location'))
48-
assert isinstance(driver.set_location('11.1', '22.2', '33.3', '23.2'), WebDriver)
49+
assert isinstance(driver.set_location('11.1', '22.2', '33.3', '23.2', '12'), WebDriver)
4950

5051
d = get_httpretty_request_body(httpretty.last_request())
5152
assert d['location']['latitude'] == '11.1'
5253
assert d['location']['longitude'] == '22.2'
5354
assert d['location']['altitude'] == '33.3'
5455
assert d['location']['speed'] == '23.2'
56+
assert d['location']['satellites'] == '12'
5557

5658
@httpretty.activate
5759
def test_set_location_without_altitude(self):

0 commit comments

Comments
 (0)