getAppStrings()

what is the best way to use getAppStrings() of the java client (which returns a single string an no array of strings?!) for language independent testing.

any pointers are greatly appreciated.

Hi @rompic,
I convert the single string to a hash map with this method:

import java.util.HashMap;
import java.util.StringTokenizer;

    private HashMap<String, String> parseAppStrings(String strings) {
        HashMap<String, String> stringsMap = new HashMap<String, String>();
        String appStringsWithoutBraces = strings.substring(1, strings.length() - 1);
        StringTokenizer st = new StringTokenizer(appStringsWithoutBraces, ",");
        while (st.hasMoreTokens()) {
            String token = st.nextToken();
            StringTokenizer st2 = new StringTokenizer(token, "=");
            if (st2.countTokens() == 2) {
                stringsMap.put(st2.nextToken().trim(), st2.nextToken().trim());
            }
        }
        return stringsMap;
    }

And then it could be used in this way:

HashMap<String, String> appStrings = parseAppStrings(driver.getAppStrings());
String value = appStrings.get('string_id');

thank you very much for your response!

maybe this could be added to the java-client?
do you think it would make sense to open a pull request? (I saw you also added the functionality https://github.com/appium/java-client/pull/23 in the first place)

I just opened a pull request: https://github.com/appium/java-client/pull/290

1 Like

Hi Gonalo,

Can you please explain me where to use and how to use. As I tried in different ways but I was unable to do it.

Kindly request you to help me by giving the code in specific and where to use it and how.

I’m facing this issue from time and trying to resolve it. As this a higher priority for me.

Please help me.

Note:
As I’m using 2.2.0 java client version and I’m able to get the "driver.getAppStrings()"
As I’m testing native app ios

Thanks in advance