Appium server command line flag to integrate with JAVA code

I wanted to know if there is a way to declare a flag in the appium server at the command line…and then somehow have the JAVA code pick up just that flag and based on that pick the appropriate driver.
Example: I am sharing test code for both iOS and Android. If I go to command line and type "appium --platform-name “iOS” " I want my JAVA code to pick that up…and then afterwards launch the iOSDriver or AndroidDriver accordingly.
Help would be greatly appreciated!

There is a platform-dependent way to do this. In your Java code running on a Unix machine, you should spawn “ps” (to list processes) with the flags to show all processes and their commands (e.g. Linux would accept “ps -elf” or “ps aux”, while BSD-derivatives like OS X use just “ps aux”). You would then parse the output to find the processes that are Appium processes, and then you can parse their command lines to know which platform Appium was given when launched.

A much cleaner and less error-prone method would be to launch your Appium server without the platform name parameter, and then you can specify the platform when your tests build their desired capabilities objects. Your tests should be dependent on whether they were written for iOS or Android systems (and so, your tests should know if they want an IOSDriver or AndroidDriver). If you have a test written to test both Android and iOS versions of your app, then you’re asking for a lot of trouble. :stuck_out_tongue:

maybe with test start?

example testNG:

mvn clean test -DsuiteXmlFile=src/test/java/recources/some_tests.xml -DappType=DEV [email protected]

read in code (java):

userEmail = System.getProperty("userEmail");