From 1cecf5f7a9950d9727b0a5e3bd853a7c72c4ef29 Mon Sep 17 00:00:00 2001 From: "ben.zhou" Date: Mon, 6 Feb 2017 11:24:59 -0600 Subject: [PATCH 1/2] Added get_page_source command. --- appium/webdriver/mobilecommand.py | 3 ++- appium/webdriver/webdriver.py | 10 +++++++++- test/functional/ios/appium_tests.py | 5 +++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/appium/webdriver/mobilecommand.py b/appium/webdriver/mobilecommand.py index b0a2e6542..b4de0b177 100644 --- a/appium/webdriver/mobilecommand.py +++ b/appium/webdriver/mobilecommand.py @@ -58,4 +58,5 @@ class MobileCommand(object): UPDATE_SETTINGS = 'updateSettings' SET_LOCATION = 'setLocation' GET_DEVICE_TIME = 'getDeviceTime' - CLEAR = 'clear' \ No newline at end of file + CLEAR = 'clear' + SOURCE = 'source' diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py index 698e6bb6f..4d1b701a9 100644 --- a/appium/webdriver/webdriver.py +++ b/appium/webdriver/webdriver.py @@ -760,9 +760,14 @@ def set_location(self, latitude, longitude, altitude): self.execute(Command.SET_LOCATION, data) return self + def get_page_source(self): + """Returns the current page source. + """ + return self.execute(Command.SOURCE, {})['value'] + @property def device_time(self): - """Returns the date and time fomr the device + """Returns the date and time from the device """ return self.execute(Command.GET_DEVICE_TIME, {})['value'] @@ -854,3 +859,6 @@ def _addCommands(self): ('GET', '/session/$sessionId/appium/device/system_time') self.command_executor._commands[Command.CLEAR] = \ ('POST', '/session/$sessionId/element/$id/clear') + self.command_executor._commands[Command.SOURCE] = \ + ('GET', '/session/$sessionId/source') + diff --git a/test/functional/ios/appium_tests.py b/test/functional/ios/appium_tests.py index 10d4c3e98..9783b5df3 100644 --- a/test/functional/ios/appium_tests.py +++ b/test/functional/ios/appium_tests.py @@ -28,6 +28,11 @@ def setUp(self): def tearDown(self): self.driver.quit() + + def test_get_page_source(self): + source = self.driver.get_page_source() + print source + def test_lock(self): el = self.driver.find_element_by_id('ButtonsExplain') self.assertIsNotNone(el) From d0ac8a957d22d2e7a5680e8376101d727ace9781 Mon Sep 17 00:00:00 2001 From: "ben.zhou" Date: Wed, 12 Apr 2017 11:09:33 -0500 Subject: [PATCH 2/2] Revert "Added get_page_source command." This reverts commit 1cecf5f7a9950d9727b0a5e3bd853a7c72c4ef29. --- appium/webdriver/mobilecommand.py | 3 +-- appium/webdriver/webdriver.py | 10 +--------- test/functional/ios/appium_tests.py | 5 ----- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/appium/webdriver/mobilecommand.py b/appium/webdriver/mobilecommand.py index b4de0b177..b0a2e6542 100644 --- a/appium/webdriver/mobilecommand.py +++ b/appium/webdriver/mobilecommand.py @@ -58,5 +58,4 @@ class MobileCommand(object): UPDATE_SETTINGS = 'updateSettings' SET_LOCATION = 'setLocation' GET_DEVICE_TIME = 'getDeviceTime' - CLEAR = 'clear' - SOURCE = 'source' + CLEAR = 'clear' \ No newline at end of file diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py index 4d1b701a9..698e6bb6f 100644 --- a/appium/webdriver/webdriver.py +++ b/appium/webdriver/webdriver.py @@ -760,14 +760,9 @@ def set_location(self, latitude, longitude, altitude): self.execute(Command.SET_LOCATION, data) return self - def get_page_source(self): - """Returns the current page source. - """ - return self.execute(Command.SOURCE, {})['value'] - @property def device_time(self): - """Returns the date and time from the device + """Returns the date and time fomr the device """ return self.execute(Command.GET_DEVICE_TIME, {})['value'] @@ -859,6 +854,3 @@ def _addCommands(self): ('GET', '/session/$sessionId/appium/device/system_time') self.command_executor._commands[Command.CLEAR] = \ ('POST', '/session/$sessionId/element/$id/clear') - self.command_executor._commands[Command.SOURCE] = \ - ('GET', '/session/$sessionId/source') - diff --git a/test/functional/ios/appium_tests.py b/test/functional/ios/appium_tests.py index 9783b5df3..10d4c3e98 100644 --- a/test/functional/ios/appium_tests.py +++ b/test/functional/ios/appium_tests.py @@ -28,11 +28,6 @@ def setUp(self): def tearDown(self): self.driver.quit() - - def test_get_page_source(self): - source = self.driver.get_page_source() - print source - def test_lock(self): el = self.driver.find_element_by_id('ButtonsExplain') self.assertIsNotNone(el)