Start/Kill appium server within java code

Hi,

I have to start and stop appium server (node) on mac machine using java code from a windows machine

is it possible and if it so can i have the code pls
Thanks in advance

Sugu

Hello All,

Please check the below link from my blog,

Regards,
A. K. Sahu

Hi
I am getting Invalid character error with code 800A03F6. Please help.

Hi Priyank_Shah

I was using this to Start/Stop my Appium Server. It has been working for the past 3 months. But now i upgrade to Appium 1.4.16.1 and this doesn’t start the Appium Server and doesn’t throws any error. Please let me know if I am doing anything wrong.

public class SampleJavaTest {
private static Process process;
public static String APPIUM_NODE_FILEPATH = “C:/Program Files (x86)/Appium/node.exe”;
public static String APPIUM_SERVERSCRIPT_FILEPATH = “C:/Program Files (x86)/Appium/node_modules/appium/bin/appium.js”;

public static String APPIUMSERVERSTART = “”" + APPIUM_NODE_FILEPATH + “” “” + APPIUM_SERVERSCRIPT_FILEPATH + “” ";

public void startServer() throws IOException, InterruptedException
{
Runtime runtime = Runtime.getRuntime();
process = runtime.exec(APPIUMSERVERSTART);
Thread.sleep(5000);
if (process != null)
{
System.out.println(“Appium server started”);
}
}

/**

  • DOCUMENT ME!
    */
    public void stopServer()
    {
    if (process != null)
    {
    process.destroy();
    }
    System.out.println(“Appium server stop”);
    }

public static void main(String args[]) throws IOException, InterruptedException {
startAppiumServer();
stopAppiumServer();
}

I don’t have a solution to your problem but you may want to look into the new version of the java-client which supports starting the server from java and offers, as far as I can see, a very elegant solution.


1 Like

Hello Friend,

Please try the code that I posted in my post http://aksahu.blogspot.in/2015/10/start-and-stop-appium-server.html

Hope it will help you!

Thanks,
Aswini Kumar

Hi All,

I had found couple of github repo which has got really optimized code; showing this plus running test cases on multiple device parallel or distributed way.

Thanks to saikrishna321 for sharing this knowledge with community.

Regards,
Vikram

Hi,

I have posted detailed explanation on starting and stopping Appium server with java code which works in windows as well as in Linux.

Regards,
Anuja

Thanks for all the help! I got it working.

Thanks, most welcome… hope people are finding it usefull… i’m currently working on extending this to cucumber-jvm where u can run your features in parallel and distributed way …

@saikrishna321 You Are AWESOME :crown:

I will also like to contribute to your repo in coming weeks.

2 Likes

Thanks !!

This is very useful code.

Thats awesome… looking forward for it :smile:

For anybody reading this who happens to be using npm (node/js/typescript), I’ve created a module called appium-controller that starts and stops appium in the background programmatically… appium logs are stored as well.