I am thinking about these variants… AndroidDriver and IOSDriver require remote URL. If node has been launched automatically or before test script is started they need to know port. If we could receive actual port number we would use:
new AndroidDriver(Capabilities);
new IOSDriver(Capabilities);
What are you think about it? Above is for the local starting.
You can use the following command to accomplish that:
echo off & FOR /F “usebackq tokens=2” %a in (TASKLIST ^| findstr /I node.exe) do (FOR /F “usebackq tokens=2” %b in (netstat -nao ^| findstr /R /C:"%a") do echo %b)
Run it from inside your Java application, parse the returned value and get the port number from it
@Hassan_Radi
I tried your suggestion for starting appium server through the following java code.
Somehow the server is not starting.When i check using the command sudo lsof -i :4723 there are no process running on the port 4723.
But when i try the same command manually in a terminal without /bin/sh the server starts successfully
Am i missing something here?
I am using Java 8 , Xcode 6.1 , MAC 10.10, Appium 1.3.1
Hi folks first of all thanks for helping me overcome this obstacle.
at the end my solution for starting & stopping the Appium server was simple,
i created 2 shell scripts files, one for starting the server & the other for stopping it.
Start server file include the following data:
/Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js --address 127.0.0.1 --chromedriver-port 9516 --bootstrap-port 4725 --no-reset --local-timezone
Stop server file include the following data:
killall node
The java code for starting & Stopping the server was:
//Start Appium server
Runtime.getRuntime().exec("/startAppium");
//Stop Appium server
Runtime.getRuntime().exec("/stopAppium");
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”;
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.
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.
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 …