1

Is there a way I can use xcrun simctl commands in my Appium automation? I have came to situation where I wanted to use uninstall and install app from simulator which is not available with appium methods. So, I am thinking if somehow I could use this utility in automation code.

I am running my automation on iOS in Java.

bluish
  • 26,356
  • 27
  • 122
  • 180
aksdch11
  • 683
  • 6
  • 14
  • 1
    Have you tried starting the appium server with --full-reset option, I think that option will remove the app after the tests – Balaji Sekar Jan 08 '15 at 23:19
  • Also feel free to submit a pull-request to Appium, to add the feature you need. Appium uses simctl for some things already: https://github.com/appium/node-simctl – TinyTimZamboni Jan 09 '15 at 09:06
  • Thanks.. @BalajiSekar Yes I have been using full-reset till now but my app code is creating problem if full reset simulator. – aksdch11 Jan 12 '15 at 00:38
  • @TinyTimZamboni Yes, I think this is something unique I wanted. I am thinking of collaborating there. – aksdch11 Jan 12 '15 at 00:38

1 Answers1

0
public class XCRunUtil {

ProcessBuilder processBuilder = new ProcessBuilder();

Process process;

public void execute(String url) {
    String link = "xcrun simctl list devices";
    System.out.println("link : " + link);
    processBuilder.command("sh", "-c", link);
    try {
        process = processBuilder.start();

        BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
        BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream()));

        System.out.println("Here is the standard output of the command:\n");
        String s = null;
        while ((s = stdInput.readLine()) != null) {
            System.out.println(s);
        }
        // Read any errors from the attempted command
        System.out.println("Here is the standard error of the command (if any):\n");
        while ((s = stdError.readLine()) != null) {
            System.out.println(s);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}

}

This above code will works

Balakrishnan
  • 279
  • 2
  • 7