Launching and stopping appium server programmtically


#61

Hi @Hassan_Radi can you help me in this thread please


#62

How can i start the server and stop it from ruby programmatically?


#63

hi bro can you tell me how i can do this in c# please in mac platform…how can i start the server and also give my app path for the simulator to open the app.?


#64

@Hassan_Radi: Thanks for your great support , while this is still under my work , I have another priority issue than this one. If you have time , could you please respond to below mentioned issue which I have to clear ASAP.

IOS App not signing in with correct credentials using Automation Code

Regards,
Kiran


pinned #65

#66

hey hi,
I am new to the appium i want to launch appium in ubuntu, want to know how to write test scripts…
any help would be very helpful.
thanks in advance.


#67

There is no Appium Gui and Inspector for Ubuntu???


#68

Hi,

I’m not sure about iOS devices as I’m able to run them on Mac’s only, however you could install Android sdk’s where you can use tools/uiautomatorviewer for getting more info about your Android app


#69

HI,
i have already installed android sdk also i have develop my app to test , but want to know how to start appium with my app also want to how to write tests cases and to run tests on my app???


#70

Hey, seems you are not in correct topic:-)
Please look around other topics on the discuss as this topic about exact problem - launch appium programatically


#71

Hi,
i did all the mentioned setup. But when i try to launch appium from cmd by triggering the appium.js file i get a windows error. I even get the same error when i manually double click on the appium.js file.
But i am able to launch appium from the .exe file and run my tests on both physical device and emulators.
Am i doing anything wrong???


#72

Please attach a screenshot of the error message or share your piece of code. Tell us more about what you are experiencing in order for us to be able to help you :smile:

P.S. Manually clicking the Appium.js file won’t help at all :smile:


#73

Hi Hasan,

It’s unbelievable, I’ve faced the same issue with ProcessBuilder like you just only now:-) I don;t know why it works previously and I why it doesn’t work now.
However, I started using apache commons exec for parallel running and it works like a charm:-)

So start is:
private Executor appiumProcess;
CommandLine cmdLine = new CommandLine(command);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
ExecuteWatchdog watchdog = new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT);
PumpStreamHandler streamHandler = new PumpStreamHandler(new FileOutputStream(“Device” + deviceIndex + “Logs.txt”));
appiumProcess = new DefaultExecutor();
appiumProcess.setExitValue(0);
appiumProcess.setWatchdog(watchdog);
appiumProcess.setStreamHandler(streamHandler);
appiumProcess.execute(command, resultHandler);

Stop is simple:
appiumProcess.getWatchdog().destroyProcess();

Cmd creation smth like that:
CommandLine cmd = new CommandLine(“node”);
cmd.addArgument(PropertyLoader.get(“appium.path”));
cmd.addArgument("-a");
cmd.addArgument(PropertyLoader.get(“appium.host”));
cmd.addArgument("-p");
cmd.addArgument(String.valueOf(Integer.parseInt(PropertyLoader.get(“appium.port”)) + deviceIndex));
cmd.addArgument("-bp");
cmd.addArgument(String.valueOf(Integer.parseInt(PropertyLoader.get(“appium.bootstrapPort”)) + deviceIndex));
cmd.addArgument("-U");
cmd.addArgument(device.getUDID());


#74

Please let me know Steps for MAC.
Thanks,
AJ.


#75

In my case I am Using iOS Application…so Please Help me out …
As MY Application File Name Extension is DemoApp.app

Please send me code snippet if poossible.
Thanks,
Aiit.


#76

Hello Husain,

In My case I am Getting Error as:

ERROR: The process “node.exe” not found

__I am trying to launch Appium Server for Android Application Testing on Android Simulator.


#77

Please provide your code snippet that led to this error?? :smile:


#78

Yah …Here it is:

package SampleTest;

import io.appium.java_client.AppiumDriver;

import java.io.File;
import java.io.IOException;

import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecuteResultHandler;
import org.apache.commons.exec.DefaultExecutor;

import java.io.;
import java.util.
;

import jxl.Workbook;
import jxl.read.biff.BiffException;

public class AppiumServer {

public void startServer(){
CommandLine command = new CommandLine(“cmd”);
command.addArgument("/c");
command.addArgument(“D:\My_DEMO\Appium\Appium\node.exe”);
command.addArgument(“D:\My_DEMO\Appium\Appium\node_modules\appium\lib\appium.js”);
command.addArgument("–address");
command.addArgument(“127.0.0.1”);
command.addArgument("–port");
command.addArgument(“4724”);
command.addArgument("–no-reset");
command.addArgument("–log");
command.addArgument(“D:/appiumLogs.txt”);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);

try {
executor.execute(command, resultHandler);
} catch (IOException e) {
e.printStackTrace();
}
}

public void stopServer(){

CommandLine command = new CommandLine(“cmd”);
command.addArgument("/c");
command.addArgument(“taskkill”);
command.addArgument("/F");
command.addArgument("/IM");
command.addArgument(“node.exe”);

DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);

try {
executor.execute(command, resultHandler);
} catch (IOException e) {
e.printStackTrace();
}

}

public static void main(String[] args) throws BiffException, IOException {
AppiumServer server=new AppiumServer();
System.out.println("---- Starting appium server ----");
server.startServer();
System.out.println("---- Appium server started Successfully ! ----");

try{Thread.sleep(10000);}catch(Exception e){}

System.out.println("---- Stoping appium server ----");
server.stopServer();
System.out.println("---- Appium server stopped Successfully ! ----");

}

}


#79

Try putting your Appium files in C directory and give it another try.


#80

tried…no Change…getting same Error…now Check this out plz…

package myBeepsTest;

import io.appium.java_client.AppiumDriver;

import java.io.File;
import java.io.IOException;

import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecuteResultHandler;
import org.apache.commons.exec.DefaultExecutor;

import java.io.;
import java.util.
;

import jxl.Workbook;
import jxl.read.biff.BiffException;

public class AppiumServer {

public void startAppiumServer() throws IOException, InterruptedException {   
      
    CommandLine command = new CommandLine("cmd");
    command.addArgument("/c");  
    command.addArgument("c:/Appium/node.exe");  
    command.addArgument("c:/Appium/node_modules/appium/lib/appium.js");  
    command.addArgument("--address", false);  
    command.addArgument("127.0.0.1");  
    command.addArgument("--port", false);  
    command.addArgument("4723");  
    command.addArgument("--full-reset", false);  

    command.addArgument("C:/Appium/node.exe C:/Appium/node_modules/appium/bin/Appium.js --address 127.0.0.1 --chromedriver-port 9516 --bootstrap-port 4725 --selendroid-port 8082 --no-reset --local-timezone");
    
    DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();  
    DefaultExecutor executor = new DefaultExecutor();  
    executor.setExitValue(1);  
    executor.execute(command, resultHandler);  
  
}


public  void stopAppiumServer() throws IOException {  
    CommandLine command = new CommandLine("cmd");  
    command.addArgument("/c");  
    command.addArgument("Taskkill /F /IM node.exe");  
  
    DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();  
    DefaultExecutor executor = new DefaultExecutor();  
    executor.setExitValue(1);  
    executor.execute(command, resultHandler);  
     
}

public static void main(String as[]) throws IOException, InterruptedException
{
    AppiumServer aps = new AppiumServer();
    System.out.println("Starting Server...");
    aps.startAppiumServer();
    System.out.println("Server Started....");
    try{Thread.sleep(5000);}catch(Exception e){}
    System.out.println("Stopping Server");
    aps.stopAppiumServer();
    System.out.println("Server Stopped");
}

}