Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Copyright 2014-2015 Appium Contributors
Copyright 2014-2016 Appium Contributors
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ More can be found in the docs, but here's a quick list of features which this pr

- startActivity()
- resetApp()
- getAppStrings()
- getAppStringMap()
- pressKeyCode()
- longPressKeyCode()
- longPressKey()
Expand Down Expand Up @@ -108,11 +108,14 @@ If you are working on this project and use Intellij Idea, you need to change the
If you are using the Eclipse IDE, make sure you are using version Luna or later.

##Changelog##
*4.0.0 (still not released)*
- `getAppStrings()` methods now return a map with the app strings keys and values, instead of an string
*3.4.0 (still not released)*
- Update to Selenium v2.50.0
- `getAppStrings()` methods are deprecated now. They are going to be removed. `getAppStringMap()` methods were added and now return a map with app strings (keys and values)
instead of a string. Thanks to [@rgonalo](https://github.com/rgonalo) for the contribution.
- Add `getAppStrings(String language, String stringFile)` method to allow searching app strings in the specified file
- FIXED of the bug which causes deadlocks of AppiumDriver LocalService in multithreading. Thanks to [saikrishna321](https://github.com/saikrishna321) for the [bug report](https://github.com/appium/java-client/issues/283).
- Fixed Zoom methods, thanks to @kkhaidukov
- FIXED Zoom methods, thanks to [@kkhaidukov](https://github.com/kkhaidukov)
- FIXED The issue of compatibility of AppiumServiceBuilder with Appium node server v >= 1.5.x. Take a look at [#305](https://github.com/appium/java-client/issues/305)

*3.3.0*
- updated the dependency on Selenium to version 2.48.2
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.48.2</version>
<version>2.50.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
33 changes: 27 additions & 6 deletions src/main/java/io/appium/java_client/AppiumDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,34 @@ public void setLocation(Location location) {
locationContext.setLocation(location);
}

@Deprecated
/**
* This method is deprecated. It is going to be removed in the next release.
* Be careful.
*/
public String getAppStrings() {
Response response = execute(GET_STRINGS);
return response.getValue().toString();
}

@Deprecated
/**
* This method is deprecated. It is going to be removed in the next release.
* Be careful.
*/
public String getAppStrings(String language) {
Response response = execute(GET_STRINGS,
getCommandImmutableMap(LANGUAGE_PARAM, language));
return response.getValue().toString();
}

/**
* @return a map with localized strings defined in the app
*
* @see HasAppStrings#getAppStrings()
* @see HasAppStrings#getAppStringMap()
*/
@Override
public Map<String, String> getAppStrings() {
public Map<String, String> getAppStringMap() {
Response response = execute(GET_STRINGS);
return (Map<String, String>) response.getValue();
}
Expand All @@ -619,10 +640,10 @@ public Map<String, String> getAppStrings() {
* strings language code
* @return a map with localized strings defined in the app
*
* @see HasAppStrings#getAppStrings(String)
* @see HasAppStrings#getAppStringMap(String)
*/
@Override
public Map<String, String> getAppStrings(String language) {
public Map<String, String> getAppStringMap(String language) {
Response response = execute(GET_STRINGS,
getCommandImmutableMap(LANGUAGE_PARAM, language));
return (Map<String, String>) response.getValue();
Expand All @@ -635,10 +656,10 @@ public Map<String, String> getAppStrings(String language) {
* strings filename
* @return a map with localized strings defined in the app
*
* @see HasAppStrings#getAppStrings(String, String)
* @see HasAppStrings#getAppStringMap(String, String)
*/
@Override
public Map<String, String> getAppStrings(String language, String stringFile) {
public Map<String, String> getAppStringMap(String language, String stringFile) {
String[] parameters = new String[] { LANGUAGE_PARAM, STRING_FILE_PARAM };
Object[] values = new Object[] { language, stringFile };
Response response = execute(GET_STRINGS,
Expand Down
20 changes: 17 additions & 3 deletions src/main/java/io/appium/java_client/HasAppStrings.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,26 @@

public interface HasAppStrings {

@Deprecated
/**
* This method is deprecated. It is going to be removed in the next release.
* Be careful.
*/
public String getAppStrings();

@Deprecated
/**
* This method is deprecated. It is going to be removed in the next release.
* Be careful.
*/
String getAppStrings(String language);

/**
* Get all defined Strings from an app for the default language
*
* @return a map with localized strings defined in the app
*/
Map<String, String> getAppStrings();
Map<String, String> getAppStringMap();

/**
* Get all defined Strings from an app for the specified language
Expand All @@ -34,7 +48,7 @@ public interface HasAppStrings {
* strings language code
* @return a map with localized strings defined in the app
*/
Map<String, String> getAppStrings(String language);
Map<String, String> getAppStringMap(String language);

/**
* Get all defined Strings from an app for the specified language and
Expand All @@ -46,6 +60,6 @@ public interface HasAppStrings {
* strings filename
* @return a map with localized strings defined in the app
*/
Map<String, String> getAppStrings(String language, String stringFile);
Map<String, String> getAppStringMap(String language, String stringFile);

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,36 @@

public final class AppiumServiceBuilder extends DriverService.Builder<AppiumDriverLocalService, AppiumServiceBuilder> {

/**
* The environmental variable used to define
* the path to executable appium.js (node server v<=1.4.x) or
* main.js (node server v>=1.5.x)
*/
public static final String APPIUM_PATH = "APPIUM_BINARY_PATH";

/**
* The environmental variable used to define
* the path to executable NodeJS file (node.exe for WIN and
* node for Linux/MacOS X)
*/
public static final String NODE_PATH = "NODE_BINARY_PATH";

private static final String APPIUM_FOLDER = "appium";

private static final String BIN_FOLDER = "bin";
private static final String BUILD_FOLDER = "build";
private static final String LIB_FOLDER = "lib";

private static final String APPIUM_JS = "appium.js";
private static final String APPIUM_NODE_MASK = File.separator +
APPIUM_FOLDER + File.separator + BIN_FOLDER + File.separator + APPIUM_JS;
private static final String MAIN_JS = "main.js";

private static final String ERROR_NODE_NOT_FOUND = "There is no installed nodes! Please " +
"install node via NPM (https://www.npmjs.com/package/appium#using-node-js) or download and " +
"install Appium app (http://appium.io/downloads.html)";

private static final String APPIUM_NODE_MASK_OLD = File.separator + BIN_FOLDER + File.separator + APPIUM_JS;
private static final String APPIUM_NODE_MASK = File.separator + BUILD_FOLDER + File.separator + LIB_FOLDER +
File.separator + MAIN_JS;

public static final String DEFAULT_LOCAL_IP_ADDRESS = "0.0.0.0";

Expand Down Expand Up @@ -100,16 +122,28 @@ private File findNodeInCurrentFileSystem(){

instancePath = (commandLine.getStdOut()).trim();
try {
File result;
if (StringUtils.isBlank(instancePath) || !(result = new File(instancePath + File.separator +
APPIUM_NODE_MASK)).exists()) {
File defaultAppiumNode;
if (StringUtils.isBlank(instancePath) || !(defaultAppiumNode = new File(instancePath + File.separator +
APPIUM_FOLDER)).exists()) {
String errorOutput = commandLine.getStdOut();
throw new InvalidServerInstanceException("There is no installed nodes! Please install " +
" node via NPM (https://www.npmjs.com/package/appium#using-node-js) or download and " +
"install Appium app (http://appium.io/downloads.html)",
throw new InvalidServerInstanceException(ERROR_NODE_NOT_FOUND,
new IOException(errorOutput));
}
return result;

File oldResult;
//older appium server
if ((oldResult = new File(defaultAppiumNode, APPIUM_NODE_MASK_OLD)).exists()) {
return oldResult;
}
//appium servers v1.5.x and higher
File newResult;
if ((newResult = new File(defaultAppiumNode, APPIUM_NODE_MASK)).exists()) {
return newResult;
}

throw new InvalidServerInstanceException(ERROR_NODE_NOT_FOUND,
new IOException("Could not find file neither " + APPIUM_NODE_MASK_OLD + " nor " + APPIUM_NODE_MASK + " in the " +
defaultAppiumNode + " directory"));
}
finally {
commandLine.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,4 @@ public class InvalidServerInstanceException extends RuntimeException {
public InvalidServerInstanceException(String messege, Throwable t){
super(MESSAGE_PREFIX + messege, t);
}

public InvalidServerInstanceException(String messege){
super(MESSAGE_PREFIX + messege);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ private String currentActivity() {

@Test
public void getStringsTest() {
Map<String, String> strings = driver.getAppStrings();
Map<String, String> strings = driver.getAppStringMap();
assertTrue(strings.size() > 100);
}

@Test
public void getStringsWithLanguageTest() {
Map<String, String> strings = driver.getAppStrings("en");
Map<String, String> strings = driver.getAppStringMap("en");
assertTrue(strings.size() > 100);
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/io/appium/java_client/ios/IOSDriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,25 @@ public void tearDown() throws Exception {

@Test
public void getStringsTest() {
Map<String, String> strings = driver.getAppStrings();
Map<String, String> strings = driver.getAppStringMap();
assertTrue(strings.size() > 10);
}

@Test
public void getStringsWithLanguageTest() {
Map<String, String> strings = driver.getAppStrings("en");
Map<String, String> strings = driver.getAppStringMap("en");
assertTrue(strings.size() > 10);
}

@Test
public void getStringsWithLanguageAndStringFileTest() {
Map<String, String> strings = driver.getAppStrings("en", "Localizable.strings");
Map<String, String> strings = driver.getAppStringMap("en", "Localizable.strings");
assertTrue(strings.size() > 10);
}

@Test
public void getStringsWithUnknownStringFileTest() {
Map<String, String> strings = driver.getAppStrings("en", "Unknown.strings");
Map<String, String> strings = driver.getAppStringMap("en", "Unknown.strings");
assertTrue(strings.size() > 10);
}

Expand Down