Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please post some examples of using it from java code #26

Open
VenkateshPS opened this issue Jun 2, 2017 · 15 comments
Open

please post some examples of using it from java code #26

VenkateshPS opened this issue Jun 2, 2017 · 15 comments
Labels

Comments

@VenkateshPS
Copy link

@isonic1
could you post some examples of using flick from java code or please point me if there is already some.

@shapovalovei
Copy link

shapovalovei commented Jun 5, 2017

@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);

@VenkateshPS
Copy link
Author

Thanks @shapovalovei

@VenkateshPS
Copy link
Author

@shapovalovei

what is the command to fetch device vitals(memory, cpu)

@shapovalovei
Copy link

shapovalovei commented Jun 6, 2017

@VenkateshPS Your question how to get memory and CPU from the device ?

@VenkateshPS
Copy link
Author

VenkateshPS commented Jun 6, 2017

@shapovalovei yes , will this help $ flick vitals -n com.package.name ?

@saikrishna321
Copy link

@VenkateshPS flick as library helps you capture video from android and iOS device, you cannot get device stats from this library

@shapovalovei
Copy link

@VenkateshPS #23

@VenkateshPS
Copy link
Author

@shapovalovei @saikrishna321 Thanks , are you aware of some libraries which can get device vitals during Automation runs.

@shapovalovei
Copy link

shapovalovei commented Jun 6, 2017

@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.

@isonic1
Copy link
Owner

isonic1 commented Jun 6, 2017

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.

@VenkateshPS
Copy link
Author

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

@isonic1
Copy link
Owner

isonic1 commented Jun 14, 2017

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

@VenkateshPS
Copy link
Author

Thanks @isonic1

@pavanbachu0604
Copy link

@isonic1 : Any luck wth capturing iOS vitals ?

@JeevaTamil
Copy link

@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants