Open VenkateshPS opened 7 years ago
@VenkateshPS Hi, I try to help you.
In my project, I use DefaultExecutor
For example:
public static int runShell(String command, String arguments) {
CommandLine commandLine = new CommandLine(command).addArguments(arguments);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream);
DefaultExecuteResultHandler executeResultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setStreamHandler(streamHandler);
executor.setExitValue(0);
try {
log.info(String.format("Running: %s %s", command, arguments));
executor.execute(commandLine, executeResultHandler);
executeResultHandler.waitFor();
int exitCode = executeResultHandler.getExitValue();
String output = outputStream.toString();
log.info("Command executed. Exit code: " + exitCode);
log.info("Message: " + output);
TestGlobalsManager.setTestGlobal("OUTPUT", output);
} catch (IOException | InterruptedException e) {
log.error("Cannot execute command: " + e.toString());
}
return executeResultHandler.getExitValue();
}
After that, you can call this function
String arguments = String.format("video -a start -p %s -u %s -e true", Config.PLATFORM_NAME.toLowerCase(), Config.DEVICE_UID);
CommonFunctions.runShell("flick", arguments);
Thanks @shapovalovei
@shapovalovei
what is the command to fetch device vitals(memory, cpu)
@VenkateshPS Your question how to get memory and CPU from the device ?
@shapovalovei yes , will this help $ flick vitals -n com.package.name ?
@VenkateshPS flick as library helps you capture video from android and iOS device, you cannot get device stats from this library
@VenkateshPS #23
@shapovalovei @saikrishna321 Thanks , are you aware of some libraries which can get device vitals during Automation runs.
@VenkateshPS I think you can use ADB for Android devices.
for example:
adb shell dumpsys cpuinfo
adb shell dumpsys meminfo 'your apps package name'
and in code just parse values needed. then we just printed them in test logs and just manually looked through them.
Hey guys - Flick vitals are android only. So you YOU CAN get memory and cpu info for both the app and device for Android. You CANNOT get this information for iOS. If anyone comes across a tool to capture this for iOS I'd gladly add it to Flick.
@shapovalovei thank you for you assistance in answering @VenkateshPS question.
I tried using
flick vitals -p android -n com.xxxxx.xxx -u 3208df540c2471a1, but get below error even if app is installed and i am passing the correct package name
com.xxxxx.xxx was not found on device 3208df540c2471a1! Please choose one from above. e.g. package:com.samsung.android.asksmanager
Make sure the package name and UUID are correct. Can you see the package listed when running this command adb -s #{udid} shell pm list packages
?
flick vitals -p android -n com.myawesomeapp.com
Thanks @isonic1
@isonic1 : Any luck wth capturing iOS vitals ?
@shapovalovei Above java code is not working for me. iOS - 11.3 MacOS - 10.13.2
Note: Output of the above code
Command executed. Exit code: -559038737 Message:
But I can do the same via terminal. Please guide me to use flick in my Appium test script(java)
@isonic1 could you post some examples of using flick from java code or please point me if there is already some.