Skip to content
Open
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: 1 addition & 11 deletions appium/webdriver/extensions/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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')
1 change: 0 additions & 1 deletion appium/webdriver/mobilecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 3 additions & 1 deletion test/unit/webdriver/device/location_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading