Skip to content

Commit b492593

Browse files
committed
Merge pull request #61 from appium/isaac-tls
Add toggle_location_services
2 parents f85f6b1 + 002c902 commit b492593

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

appium/webdriver/mobilecommand.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class MobileCommand(object):
2727
ACTIVATE_IME_ENGINE = 'activateIMEEngine'
2828
DEACTIVATE_IME_ENGINE = 'deactivateIMEEngine'
2929
GET_ACTIVE_IME_ENGINE = 'getActiveEngine'
30+
TOGGLE_LOCATION_SERVICES = 'toggleLocationServices'
3031

3132
# Appium Commands
3233
GET_APP_STRINGS = 'getAppStrings'

appium/webdriver/webdriver.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,13 @@ def update_settings(self, settings):
672672
self.execute(Command.UPDATE_SETTINGS, data)
673673
return self
674674

675+
def toggle_location_services(self):
676+
"""Toggle the location services on the device. Android only.
677+
"""
678+
self.execute(Command.TOGGLE_LOCATION_SERVICES, {})
679+
return self
680+
681+
675682
def _addCommands(self):
676683
self.command_executor._commands[Command.CONTEXTS] = \
677684
('GET', '/session/$sessionId/contexts')
@@ -748,6 +755,8 @@ def _addCommands(self):
748755
('GET', '/session/$sessionId/appium/settings')
749756
self.command_executor._commands[Command.UPDATE_SETTINGS] = \
750757
('POST', '/session/$sessionId/appium/settings')
758+
self.command_executor._commands[Command.TOGGLE_LOCATION_SERVICES] = \
759+
('POST', '/session/$sessionId/appium/device/toggle_location_services')
751760

752761

753762
# monkeypatched method for WebElement

test/functional/android/appium_tests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def tearDown(self):
3939
self.driver.quit()
4040

4141
# remove zipped file from `test_pull_folder`
42-
if os.path.isfile(self.zipfilename):
42+
if hasattr(self, 'zipfilename') and os.path.isfile(self.zipfilename):
4343
os.remove(self.zipfilename)
4444

4545
def test_app_strings(self):
@@ -217,6 +217,10 @@ def test_update_settings(self):
217217
settings = self.driver.get_settings()
218218
self.assertEqual(settings["cyberdelia"], "open")
219219

220+
def test_toggle_location_services(self):
221+
self.driver.toggle_location_services()
222+
223+
220224
if __name__ == "__main__":
221225
suite = unittest.TestLoader().loadTestsFromTestCase(AppiumTests)
222226
unittest.TextTestRunner(verbosity=2).run(suite)

test/functional/android/desired_capabilities.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def get_desired_capabilities(app):
2626
'platformVersion': '4.2',
2727
'deviceName': 'Android Emulator',
2828
'app': PATH('../../apps/' + app),
29+
'newCommandTimeout': 240
2930
}
3031

3132
return desired_caps

0 commit comments

Comments
 (0)