diff --git a/appium/webdriver/extensions/location.py b/appium/webdriver/extensions/location.py index 3141050a..fc1fcae2 100644 --- a/appium/webdriver/extensions/location.py +++ b/appium/webdriver/extensions/location.py @@ -14,7 +14,6 @@ from typing import Dict, Union -from selenium.common.exceptions import UnknownMethodException from typing_extensions import Self from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands @@ -33,11 +32,7 @@ def toggle_location_services(self) -> Self: Returns: Union['WebDriver', 'Location']: Self instance """ - try: - self.execute_script('mobile: toggleGps') - except UnknownMethodException: - # TODO: Remove the fallback - self.execute(Command.TOGGLE_LOCATION_SERVICES) + self.execute_script('mobile: toggleGps') return self def set_location( @@ -89,10 +84,5 @@ def location(self) -> Dict[str, float]: def _add_commands(self) -> None: """Add location endpoints. They are not int w3c spec.""" - self.command_executor.add_command( - Command.TOGGLE_LOCATION_SERVICES, - 'POST', - '/session/$sessionId/appium/device/toggle_location_services', - ) self.command_executor.add_command(Command.GET_LOCATION, 'GET', '/session/$sessionId/location') self.command_executor.add_command(Command.SET_LOCATION, 'POST', '/session/$sessionId/location') diff --git a/appium/webdriver/mobilecommand.py b/appium/webdriver/mobilecommand.py index 79ac25e1..67f0ce0a 100644 --- a/appium/webdriver/mobilecommand.py +++ b/appium/webdriver/mobilecommand.py @@ -84,7 +84,6 @@ class MobileCommand: GET_SYSTEM_BARS = 'getSystemBars' GET_DISPLAY_DENSITY = 'getDisplayDensity' TOGGLE_WIFI = 'toggleWiFi' - TOGGLE_LOCATION_SERVICES = 'toggleLocationServices' GET_PERFORMANCE_DATA_TYPES = 'getPerformanceDataTypes' GET_PERFORMANCE_DATA = 'getPerformanceData' GET_NETWORK_CONNECTION = 'getNetworkConnection' diff --git a/test/unit/webdriver/device/location_test.py b/test/unit/webdriver/device/location_test.py index fb0112bc..f09820b3 100644 --- a/test/unit/webdriver/device/location_test.py +++ b/test/unit/webdriver/device/location_test.py @@ -24,10 +24,12 @@ class TestWebDriverLocation(object): @httpretty.activate def test_toggle_location_services(self): driver = android_w3c_driver() - httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/appium/device/toggle_location_services')) httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync')) assert isinstance(driver.toggle_location_services(), WebDriver) + d = get_httpretty_request_body(httpretty.last_request()) + assert d['script'] == 'mobile: toggleGps' + @httpretty.activate def test_set_location_float(self): driver = android_w3c_driver()