How to find app version with appium on iOS
up vote
0
down vote
favorite
When I launch my tests, I want a lots of debug informations : device used, operating system, and version of the app tested.
My problem is about the version of the app.
On Android, I use :
String line = "adb -s " + udid + " shell dumpsys package";
Runtime.getRuntime().exec(line);
After that, searching the package name and then the versionName is easy.
But how to find the same information on iOS ? I didn't find any documentation to have app informations. (and obviously, adb is not compatible with iphone)
java ios automated-tests appium
add a comment |
up vote
0
down vote
favorite
When I launch my tests, I want a lots of debug informations : device used, operating system, and version of the app tested.
My problem is about the version of the app.
On Android, I use :
String line = "adb -s " + udid + " shell dumpsys package";
Runtime.getRuntime().exec(line);
After that, searching the package name and then the versionName is easy.
But how to find the same information on iOS ? I didn't find any documentation to have app informations. (and obviously, adb is not compatible with iphone)
java ios automated-tests appium
Do You use Appium for automated testing?
– Kovacic
May 18 at 9:22
Yes, I use Appium for the test.
– Fabrice31
May 18 at 9:52
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
When I launch my tests, I want a lots of debug informations : device used, operating system, and version of the app tested.
My problem is about the version of the app.
On Android, I use :
String line = "adb -s " + udid + " shell dumpsys package";
Runtime.getRuntime().exec(line);
After that, searching the package name and then the versionName is easy.
But how to find the same information on iOS ? I didn't find any documentation to have app informations. (and obviously, adb is not compatible with iphone)
java ios automated-tests appium
When I launch my tests, I want a lots of debug informations : device used, operating system, and version of the app tested.
My problem is about the version of the app.
On Android, I use :
String line = "adb -s " + udid + " shell dumpsys package";
Runtime.getRuntime().exec(line);
After that, searching the package name and then the versionName is easy.
But how to find the same information on iOS ? I didn't find any documentation to have app informations. (and obviously, adb is not compatible with iphone)
java ios automated-tests appium
java ios automated-tests appium
asked May 18 at 9:16
Fabrice31
702723
702723
Do You use Appium for automated testing?
– Kovacic
May 18 at 9:22
Yes, I use Appium for the test.
– Fabrice31
May 18 at 9:52
add a comment |
Do You use Appium for automated testing?
– Kovacic
May 18 at 9:22
Yes, I use Appium for the test.
– Fabrice31
May 18 at 9:52
Do You use Appium for automated testing?
– Kovacic
May 18 at 9:22
Do You use Appium for automated testing?
– Kovacic
May 18 at 9:22
Yes, I use Appium for the test.
– Fabrice31
May 18 at 9:52
Yes, I use Appium for the test.
– Fabrice31
May 18 at 9:52
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
You can try this. If You're using *.app You can try with this comand:
or ipa "IPA/payload/NAME.app/Info.plist"
String line = "/usr/libexec/PlistBuddy -c print Downloads/Payload/NAME.app/Info.plist | grep CFBundleVersion"
Runtime.getRuntime().exec(line);
add a comment |
up vote
0
down vote
TL;DR
Check out this article for a summary.
For iOS, you have the following options:
- Use a command line tool like
defaults
on Mac orplistutil
on Linux and call it from within your Java code usingProcessBuilder
. - Use the dd-plist library for Java
- Use the justtestlah library for Java (which wraps dd-plist and a similar library for Android apps) Disclaimer: I'm the author of this tool.
In short, if you only require iOS I suggest option 2, if you want the same approach for Android and iOS I recommend option 3.
Ad 1.
This is platform-dependent and therefore not ideal (IMO). If you are only targeting one platform to execute your tests from or don't mind maintaining multiple and also don't mind installing some additional tools this works fine though.
These are the commands to retrieve the version information. Similarly, you can also query other metadata from the app packages.
Mac OS:
defaults read /path/test.app/Info CFBundleShortVersionString
defaults read /path/test.app/Info CFBundleVersion
Linux:
plistutil -i /path/test.app/Info | xmllint --xpath "//key[text()='CFBundleShortVersionString']/following-sibling::string[1]/text()" -
plistutil -i /path/test.app/Info | xmllint --xpath "//key[text()='CFBundleVersion']/following-sibling::string[1]/text()" -
This approach is probably most useful for use in shell scripts (e.g. in a CI pipeline).
Integrating it into a Java program will look something like this (please note that you might need to add some additional error handling if you decide to use this):
String versionName = executeCommand("defaults read /path/test.app/Info CFBundleShortVersionString");
public String executeCommand(String command) {
LOG.info("Executing command {}", command);
String shellCommand = {"/bin/sh", "-c", command};
Process process;
try {
process = new ProcessBuilder(shellCommand).start();
return Stream.of(process.getErrorStream(), process.getInputStream())
.parallel()
.map(
(InputStream inputStream) -> {
try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
return br.readLine(); // we only care about the first line
} catch (IOException e) {
throw new RuntimeException(e);
}
})
.collect(Collectors.joining());
} catch (IOException exception) {
LOG.error(String.format("Error while executing command %s", command), exception);
}
return "";
}
I did a PoC for this here. While this works fine and has the advantage of not needing any additional Java libraries, I would recommend one of the other options instead.
Ad 2.
Add the dd-list JAR file to your classpath. For example, for Maven:
<properties>
<dd.plist.version>1.21</dd.plist.version>
</properties>
<dependencies>
<dependency>
<groupId>com.googlecode.plist</groupId>
<artifactId>dd-plist</artifactId>
<version>${dd.plist.version}</version>
</dependency>
</depdencies>
Then, run the code like this:
String appPath = "/path/test.app";
NSDictionary dictionary = (NSDictionary) PropertyListParser.parse(path);
String versionName = dictionary.objectForKey(“CFBundleShortVersionString”).toString();
String versionCode = dictionary.objectForKey(“CFBundleVersion”).toString();
Ad 3.
Add the justtestlah-mobile-tools
JAR file to your classpath. For Maven:
<properties>
<justtestlah.version>1.3.2</justtestlah.version>
</properties>
<dependencies>
<dependency>
<groupId>io.github.martinschneider</groupId>
<artifactId>justtestlah-mobile-tools</artifactId>
<version>${justtestlah.version}</version>
</dependency>
</depdencies>
Then run the code like this:
ApplicationInfo appInfo = new ApplicationInfoService().getAppInfo(appPath);
String versionName = appInfo.getVersionName();
String versionCode = appInfo.getVersionCode();
String applicationName = appInfo.getApplicationName();
The added benefit of the last one is that you can use the same code for APK, APP and even IPA files.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can try this. If You're using *.app You can try with this comand:
or ipa "IPA/payload/NAME.app/Info.plist"
String line = "/usr/libexec/PlistBuddy -c print Downloads/Payload/NAME.app/Info.plist | grep CFBundleVersion"
Runtime.getRuntime().exec(line);
add a comment |
up vote
0
down vote
You can try this. If You're using *.app You can try with this comand:
or ipa "IPA/payload/NAME.app/Info.plist"
String line = "/usr/libexec/PlistBuddy -c print Downloads/Payload/NAME.app/Info.plist | grep CFBundleVersion"
Runtime.getRuntime().exec(line);
add a comment |
up vote
0
down vote
up vote
0
down vote
You can try this. If You're using *.app You can try with this comand:
or ipa "IPA/payload/NAME.app/Info.plist"
String line = "/usr/libexec/PlistBuddy -c print Downloads/Payload/NAME.app/Info.plist | grep CFBundleVersion"
Runtime.getRuntime().exec(line);
You can try this. If You're using *.app You can try with this comand:
or ipa "IPA/payload/NAME.app/Info.plist"
String line = "/usr/libexec/PlistBuddy -c print Downloads/Payload/NAME.app/Info.plist | grep CFBundleVersion"
Runtime.getRuntime().exec(line);
answered May 18 at 11:06
Kovacic
997119
997119
add a comment |
add a comment |
up vote
0
down vote
TL;DR
Check out this article for a summary.
For iOS, you have the following options:
- Use a command line tool like
defaults
on Mac orplistutil
on Linux and call it from within your Java code usingProcessBuilder
. - Use the dd-plist library for Java
- Use the justtestlah library for Java (which wraps dd-plist and a similar library for Android apps) Disclaimer: I'm the author of this tool.
In short, if you only require iOS I suggest option 2, if you want the same approach for Android and iOS I recommend option 3.
Ad 1.
This is platform-dependent and therefore not ideal (IMO). If you are only targeting one platform to execute your tests from or don't mind maintaining multiple and also don't mind installing some additional tools this works fine though.
These are the commands to retrieve the version information. Similarly, you can also query other metadata from the app packages.
Mac OS:
defaults read /path/test.app/Info CFBundleShortVersionString
defaults read /path/test.app/Info CFBundleVersion
Linux:
plistutil -i /path/test.app/Info | xmllint --xpath "//key[text()='CFBundleShortVersionString']/following-sibling::string[1]/text()" -
plistutil -i /path/test.app/Info | xmllint --xpath "//key[text()='CFBundleVersion']/following-sibling::string[1]/text()" -
This approach is probably most useful for use in shell scripts (e.g. in a CI pipeline).
Integrating it into a Java program will look something like this (please note that you might need to add some additional error handling if you decide to use this):
String versionName = executeCommand("defaults read /path/test.app/Info CFBundleShortVersionString");
public String executeCommand(String command) {
LOG.info("Executing command {}", command);
String shellCommand = {"/bin/sh", "-c", command};
Process process;
try {
process = new ProcessBuilder(shellCommand).start();
return Stream.of(process.getErrorStream(), process.getInputStream())
.parallel()
.map(
(InputStream inputStream) -> {
try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
return br.readLine(); // we only care about the first line
} catch (IOException e) {
throw new RuntimeException(e);
}
})
.collect(Collectors.joining());
} catch (IOException exception) {
LOG.error(String.format("Error while executing command %s", command), exception);
}
return "";
}
I did a PoC for this here. While this works fine and has the advantage of not needing any additional Java libraries, I would recommend one of the other options instead.
Ad 2.
Add the dd-list JAR file to your classpath. For example, for Maven:
<properties>
<dd.plist.version>1.21</dd.plist.version>
</properties>
<dependencies>
<dependency>
<groupId>com.googlecode.plist</groupId>
<artifactId>dd-plist</artifactId>
<version>${dd.plist.version}</version>
</dependency>
</depdencies>
Then, run the code like this:
String appPath = "/path/test.app";
NSDictionary dictionary = (NSDictionary) PropertyListParser.parse(path);
String versionName = dictionary.objectForKey(“CFBundleShortVersionString”).toString();
String versionCode = dictionary.objectForKey(“CFBundleVersion”).toString();
Ad 3.
Add the justtestlah-mobile-tools
JAR file to your classpath. For Maven:
<properties>
<justtestlah.version>1.3.2</justtestlah.version>
</properties>
<dependencies>
<dependency>
<groupId>io.github.martinschneider</groupId>
<artifactId>justtestlah-mobile-tools</artifactId>
<version>${justtestlah.version}</version>
</dependency>
</depdencies>
Then run the code like this:
ApplicationInfo appInfo = new ApplicationInfoService().getAppInfo(appPath);
String versionName = appInfo.getVersionName();
String versionCode = appInfo.getVersionCode();
String applicationName = appInfo.getApplicationName();
The added benefit of the last one is that you can use the same code for APK, APP and even IPA files.
add a comment |
up vote
0
down vote
TL;DR
Check out this article for a summary.
For iOS, you have the following options:
- Use a command line tool like
defaults
on Mac orplistutil
on Linux and call it from within your Java code usingProcessBuilder
. - Use the dd-plist library for Java
- Use the justtestlah library for Java (which wraps dd-plist and a similar library for Android apps) Disclaimer: I'm the author of this tool.
In short, if you only require iOS I suggest option 2, if you want the same approach for Android and iOS I recommend option 3.
Ad 1.
This is platform-dependent and therefore not ideal (IMO). If you are only targeting one platform to execute your tests from or don't mind maintaining multiple and also don't mind installing some additional tools this works fine though.
These are the commands to retrieve the version information. Similarly, you can also query other metadata from the app packages.
Mac OS:
defaults read /path/test.app/Info CFBundleShortVersionString
defaults read /path/test.app/Info CFBundleVersion
Linux:
plistutil -i /path/test.app/Info | xmllint --xpath "//key[text()='CFBundleShortVersionString']/following-sibling::string[1]/text()" -
plistutil -i /path/test.app/Info | xmllint --xpath "//key[text()='CFBundleVersion']/following-sibling::string[1]/text()" -
This approach is probably most useful for use in shell scripts (e.g. in a CI pipeline).
Integrating it into a Java program will look something like this (please note that you might need to add some additional error handling if you decide to use this):
String versionName = executeCommand("defaults read /path/test.app/Info CFBundleShortVersionString");
public String executeCommand(String command) {
LOG.info("Executing command {}", command);
String shellCommand = {"/bin/sh", "-c", command};
Process process;
try {
process = new ProcessBuilder(shellCommand).start();
return Stream.of(process.getErrorStream(), process.getInputStream())
.parallel()
.map(
(InputStream inputStream) -> {
try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
return br.readLine(); // we only care about the first line
} catch (IOException e) {
throw new RuntimeException(e);
}
})
.collect(Collectors.joining());
} catch (IOException exception) {
LOG.error(String.format("Error while executing command %s", command), exception);
}
return "";
}
I did a PoC for this here. While this works fine and has the advantage of not needing any additional Java libraries, I would recommend one of the other options instead.
Ad 2.
Add the dd-list JAR file to your classpath. For example, for Maven:
<properties>
<dd.plist.version>1.21</dd.plist.version>
</properties>
<dependencies>
<dependency>
<groupId>com.googlecode.plist</groupId>
<artifactId>dd-plist</artifactId>
<version>${dd.plist.version}</version>
</dependency>
</depdencies>
Then, run the code like this:
String appPath = "/path/test.app";
NSDictionary dictionary = (NSDictionary) PropertyListParser.parse(path);
String versionName = dictionary.objectForKey(“CFBundleShortVersionString”).toString();
String versionCode = dictionary.objectForKey(“CFBundleVersion”).toString();
Ad 3.
Add the justtestlah-mobile-tools
JAR file to your classpath. For Maven:
<properties>
<justtestlah.version>1.3.2</justtestlah.version>
</properties>
<dependencies>
<dependency>
<groupId>io.github.martinschneider</groupId>
<artifactId>justtestlah-mobile-tools</artifactId>
<version>${justtestlah.version}</version>
</dependency>
</depdencies>
Then run the code like this:
ApplicationInfo appInfo = new ApplicationInfoService().getAppInfo(appPath);
String versionName = appInfo.getVersionName();
String versionCode = appInfo.getVersionCode();
String applicationName = appInfo.getApplicationName();
The added benefit of the last one is that you can use the same code for APK, APP and even IPA files.
add a comment |
up vote
0
down vote
up vote
0
down vote
TL;DR
Check out this article for a summary.
For iOS, you have the following options:
- Use a command line tool like
defaults
on Mac orplistutil
on Linux and call it from within your Java code usingProcessBuilder
. - Use the dd-plist library for Java
- Use the justtestlah library for Java (which wraps dd-plist and a similar library for Android apps) Disclaimer: I'm the author of this tool.
In short, if you only require iOS I suggest option 2, if you want the same approach for Android and iOS I recommend option 3.
Ad 1.
This is platform-dependent and therefore not ideal (IMO). If you are only targeting one platform to execute your tests from or don't mind maintaining multiple and also don't mind installing some additional tools this works fine though.
These are the commands to retrieve the version information. Similarly, you can also query other metadata from the app packages.
Mac OS:
defaults read /path/test.app/Info CFBundleShortVersionString
defaults read /path/test.app/Info CFBundleVersion
Linux:
plistutil -i /path/test.app/Info | xmllint --xpath "//key[text()='CFBundleShortVersionString']/following-sibling::string[1]/text()" -
plistutil -i /path/test.app/Info | xmllint --xpath "//key[text()='CFBundleVersion']/following-sibling::string[1]/text()" -
This approach is probably most useful for use in shell scripts (e.g. in a CI pipeline).
Integrating it into a Java program will look something like this (please note that you might need to add some additional error handling if you decide to use this):
String versionName = executeCommand("defaults read /path/test.app/Info CFBundleShortVersionString");
public String executeCommand(String command) {
LOG.info("Executing command {}", command);
String shellCommand = {"/bin/sh", "-c", command};
Process process;
try {
process = new ProcessBuilder(shellCommand).start();
return Stream.of(process.getErrorStream(), process.getInputStream())
.parallel()
.map(
(InputStream inputStream) -> {
try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
return br.readLine(); // we only care about the first line
} catch (IOException e) {
throw new RuntimeException(e);
}
})
.collect(Collectors.joining());
} catch (IOException exception) {
LOG.error(String.format("Error while executing command %s", command), exception);
}
return "";
}
I did a PoC for this here. While this works fine and has the advantage of not needing any additional Java libraries, I would recommend one of the other options instead.
Ad 2.
Add the dd-list JAR file to your classpath. For example, for Maven:
<properties>
<dd.plist.version>1.21</dd.plist.version>
</properties>
<dependencies>
<dependency>
<groupId>com.googlecode.plist</groupId>
<artifactId>dd-plist</artifactId>
<version>${dd.plist.version}</version>
</dependency>
</depdencies>
Then, run the code like this:
String appPath = "/path/test.app";
NSDictionary dictionary = (NSDictionary) PropertyListParser.parse(path);
String versionName = dictionary.objectForKey(“CFBundleShortVersionString”).toString();
String versionCode = dictionary.objectForKey(“CFBundleVersion”).toString();
Ad 3.
Add the justtestlah-mobile-tools
JAR file to your classpath. For Maven:
<properties>
<justtestlah.version>1.3.2</justtestlah.version>
</properties>
<dependencies>
<dependency>
<groupId>io.github.martinschneider</groupId>
<artifactId>justtestlah-mobile-tools</artifactId>
<version>${justtestlah.version}</version>
</dependency>
</depdencies>
Then run the code like this:
ApplicationInfo appInfo = new ApplicationInfoService().getAppInfo(appPath);
String versionName = appInfo.getVersionName();
String versionCode = appInfo.getVersionCode();
String applicationName = appInfo.getApplicationName();
The added benefit of the last one is that you can use the same code for APK, APP and even IPA files.
TL;DR
Check out this article for a summary.
For iOS, you have the following options:
- Use a command line tool like
defaults
on Mac orplistutil
on Linux and call it from within your Java code usingProcessBuilder
. - Use the dd-plist library for Java
- Use the justtestlah library for Java (which wraps dd-plist and a similar library for Android apps) Disclaimer: I'm the author of this tool.
In short, if you only require iOS I suggest option 2, if you want the same approach for Android and iOS I recommend option 3.
Ad 1.
This is platform-dependent and therefore not ideal (IMO). If you are only targeting one platform to execute your tests from or don't mind maintaining multiple and also don't mind installing some additional tools this works fine though.
These are the commands to retrieve the version information. Similarly, you can also query other metadata from the app packages.
Mac OS:
defaults read /path/test.app/Info CFBundleShortVersionString
defaults read /path/test.app/Info CFBundleVersion
Linux:
plistutil -i /path/test.app/Info | xmllint --xpath "//key[text()='CFBundleShortVersionString']/following-sibling::string[1]/text()" -
plistutil -i /path/test.app/Info | xmllint --xpath "//key[text()='CFBundleVersion']/following-sibling::string[1]/text()" -
This approach is probably most useful for use in shell scripts (e.g. in a CI pipeline).
Integrating it into a Java program will look something like this (please note that you might need to add some additional error handling if you decide to use this):
String versionName = executeCommand("defaults read /path/test.app/Info CFBundleShortVersionString");
public String executeCommand(String command) {
LOG.info("Executing command {}", command);
String shellCommand = {"/bin/sh", "-c", command};
Process process;
try {
process = new ProcessBuilder(shellCommand).start();
return Stream.of(process.getErrorStream(), process.getInputStream())
.parallel()
.map(
(InputStream inputStream) -> {
try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
return br.readLine(); // we only care about the first line
} catch (IOException e) {
throw new RuntimeException(e);
}
})
.collect(Collectors.joining());
} catch (IOException exception) {
LOG.error(String.format("Error while executing command %s", command), exception);
}
return "";
}
I did a PoC for this here. While this works fine and has the advantage of not needing any additional Java libraries, I would recommend one of the other options instead.
Ad 2.
Add the dd-list JAR file to your classpath. For example, for Maven:
<properties>
<dd.plist.version>1.21</dd.plist.version>
</properties>
<dependencies>
<dependency>
<groupId>com.googlecode.plist</groupId>
<artifactId>dd-plist</artifactId>
<version>${dd.plist.version}</version>
</dependency>
</depdencies>
Then, run the code like this:
String appPath = "/path/test.app";
NSDictionary dictionary = (NSDictionary) PropertyListParser.parse(path);
String versionName = dictionary.objectForKey(“CFBundleShortVersionString”).toString();
String versionCode = dictionary.objectForKey(“CFBundleVersion”).toString();
Ad 3.
Add the justtestlah-mobile-tools
JAR file to your classpath. For Maven:
<properties>
<justtestlah.version>1.3.2</justtestlah.version>
</properties>
<dependencies>
<dependency>
<groupId>io.github.martinschneider</groupId>
<artifactId>justtestlah-mobile-tools</artifactId>
<version>${justtestlah.version}</version>
</dependency>
</depdencies>
Then run the code like this:
ApplicationInfo appInfo = new ApplicationInfoService().getAppInfo(appPath);
String versionName = appInfo.getVersionName();
String versionCode = appInfo.getVersionCode();
String applicationName = appInfo.getApplicationName();
The added benefit of the last one is that you can use the same code for APK, APP and even IPA files.
edited 2 days ago
answered 2 days ago
martin
1,07711933
1,07711933
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50407862%2fhow-to-find-app-version-with-appium-on-ios%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do You use Appium for automated testing?
– Kovacic
May 18 at 9:22
Yes, I use Appium for the test.
– Fabrice31
May 18 at 9:52