From 149e6d1cc080572c4e69c98f0e64e5c7b5901e17 Mon Sep 17 00:00:00 2001 From: Ruben Gonzalez Alonso Date: Thu, 17 Apr 2014 13:01:57 +0200 Subject: [PATCH] Add optional argument 'language' to app_strings --- appium/webdriver/webdriver.py | 17 ++++++++++------- test/functional/android/appium_tests.py | 6 +++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py index 68c29159..fa9af429 100644 --- a/appium/webdriver/webdriver.py +++ b/appium/webdriver/webdriver.py @@ -311,14 +311,17 @@ def zoom(self, element=None, percent=200, steps=50): self.execute_script('mobile: pinchOpen', opts) return self - @property - def app_strings(self): - """Returns the application strings from the device. + def app_strings(self, language=None): + """Returns the application strings from the device for the specified + language. - :Usage: - strings = driver.app_strings + :Args: + - language - strings language code """ - return self.execute(Command.GET_APP_STRINGS)['value'] + data = {} + if language != None: + data['language'] = language + return self.execute(Command.GET_APP_STRINGS, data)['value'] def reset(self): """Resets the current application on the device. @@ -518,7 +521,7 @@ def _addCommands(self): self.command_executor._commands[Command.MULTI_ACTION] = \ ('POST', '/session/$sessionId/touch/multi/perform') self.command_executor._commands[Command.GET_APP_STRINGS] = \ - ('GET', '/session/$sessionId/appium/app/strings') + ('POST', '/session/$sessionId/appium/app/strings') self.command_executor._commands[Command.KEY_EVENT] = \ ('POST', '/session/$sessionId/appium/device/keyevent') self.command_executor._commands[Command.GET_CURRENT_ACTIVITY] = \ diff --git a/test/functional/android/appium_tests.py b/test/functional/android/appium_tests.py index 2995c22c..9856a87b 100644 --- a/test/functional/android/appium_tests.py +++ b/test/functional/android/appium_tests.py @@ -34,7 +34,11 @@ def tearDown(self): self.driver.quit() def test_app_strings(self): - strings = self.driver.app_strings + strings = self.driver.app_strings() + self.assertEqual(u'You can\'t wipe my data, you are a monkey!', strings[u'monkey_wipe_data']) + + def test_app_strings_with_language(self): + strings = self.driver.app_strings("en") self.assertEqual(u'You can\'t wipe my data, you are a monkey!', strings[u'monkey_wipe_data']) def test_keyevent(self):