Skip to content

Commit e1dba6c

Browse files
committed
Merge pull request #23 from rgonalo/master
Add a new method getAppStrings(language) to get the strings for a specific language
2 parents 6a165af + f8a3ff1 commit e1dba6c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/main/java/io/appium/java_client/AppiumDriver.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public AppiumDriver(URL remoteAddress, Capabilities desiredCapabilities){
4343
ImmutableMap.Builder<String, CommandInfo> builder = ImmutableMap.builder();
4444
builder
4545
.put(RESET, postC("/session/:sessionId/appium/app/reset"))
46-
.put(GET_STRINGS, getC("/session/:sessionId/appium/app/strings"))
46+
.put(GET_STRINGS, postC("/session/:sessionId/appium/app/strings"))
4747
.put(KEY_EVENT, postC("/session/:sessionId/appium/device/keyevent"))
4848
.put(CURRENT_ACTIVITY, getC("/session/:sessionId/appium/device/current_activity"))
4949
.put(SET_VALUE, postC("/session/:sessionId/appium/element/:id/value"))
@@ -96,7 +96,7 @@ public void resetApp() {
9696
}
9797

9898
/**
99-
* Get all defined Strings from an Android app
99+
* Get all defined Strings from an Android app for the default language
100100
*
101101
* @return a string of all the localized strings defined in the app
102102
*/
@@ -105,6 +105,20 @@ public String getAppStrings() {
105105
return response.getValue().toString();
106106
}
107107

108+
/**
109+
* Get all defined Strings from an Android app for the specified language
110+
*
111+
* @param language strings language code
112+
* @return a string of all the localized strings defined in the app
113+
*/
114+
public String getAppStrings(String language) {
115+
ImmutableMap.Builder builder = ImmutableMap.builder();
116+
builder.put("language", language);
117+
ImmutableMap<String, Integer> parameters = builder.build();
118+
Response response = execute(GET_STRINGS, parameters);
119+
return response.getValue().toString();
120+
}
121+
108122
/**
109123
* Send a key event to the device
110124
*

src/test/java/io/appium/java_client/MobileDriverAndroidTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ public void getStringsTest() {
5757
assert(strings.length() > 100);
5858
}
5959

60+
@Test
61+
public void getStringsWithLanguageTest() {
62+
String strings = driver.getAppStrings("en");
63+
assert(strings.length() > 100);
64+
}
65+
6066
@Test
6167
public void keyEventTest() {
6268
driver.sendKeyEvent(AndroidKeyCode.HOME);

0 commit comments

Comments
 (0)