From 429b8a032319e4ed09d431b16d687b1baaaa59d0 Mon Sep 17 00:00:00 2001 From: Joshua Zhu Date: Mon, 13 Aug 2018 14:31:00 +0800 Subject: [PATCH 1/2] add toggle_wifi command --- appium/webdriver/mobilecommand.py | 1 + appium/webdriver/webdriver.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/appium/webdriver/mobilecommand.py b/appium/webdriver/mobilecommand.py index 0a30f5455..50d8e132f 100644 --- a/appium/webdriver/mobilecommand.py +++ b/appium/webdriver/mobilecommand.py @@ -28,6 +28,7 @@ class MobileCommand(object): DEACTIVATE_IME_ENGINE = 'deactivateIMEEngine' GET_ACTIVE_IME_ENGINE = 'getActiveEngine' TOGGLE_LOCATION_SERVICES = 'toggleLocationServices' + TOGGLE_WIFI = 'toggleWiFi' LOCATION_IN_VIEW = 'locationInView' # Appium Commands diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py index 5d171e65e..a738178eb 100644 --- a/appium/webdriver/webdriver.py +++ b/appium/webdriver/webdriver.py @@ -1116,6 +1116,12 @@ def update_settings(self, settings): self.execute(Command.UPDATE_SETTINGS, data) return self + def toggle_wifi(self): + """Toggle the wifi + """ + self.execute(Command.TOGGLE_WIFI, {}) + return self + def toggle_location_services(self): """Toggle the location services on the device. Android only. """ @@ -1500,6 +1506,8 @@ def _addCommands(self): ('POST', '/session/$sessionId/appium/settings') self.command_executor._commands[Command.TOGGLE_LOCATION_SERVICES] = \ ('POST', '/session/$sessionId/appium/device/toggle_location_services') + self.command_executor._commands[Command.TOGGLE_WIFI] = \ + ('POST', '/session/$sessionId/appium/device/toggle_wifi') self.command_executor._commands[Command.SET_LOCATION] = \ ('POST', '/session/$sessionId/location') self.command_executor._commands[Command.LOCATION_IN_VIEW] = \ From 8b1b1307f4f9ff231da7549ff235fd719fe00bff Mon Sep 17 00:00:00 2001 From: Joshua Zhu Date: Mon, 13 Aug 2018 15:01:01 +0800 Subject: [PATCH 2/2] update comment to indicate toggle_wifi is only for Android --- appium/webdriver/webdriver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py index a738178eb..4e2043e75 100644 --- a/appium/webdriver/webdriver.py +++ b/appium/webdriver/webdriver.py @@ -1117,7 +1117,7 @@ def update_settings(self, settings): return self def toggle_wifi(self): - """Toggle the wifi + """Toggle the wifi on the device, Android only. """ self.execute(Command.TOGGLE_WIFI, {}) return self