After a lot of trying I succeed to activate appium (JAVA) pragmatically in parallel,
This is my code that works now:
public DesiredCapabilities cap = new DesiredCapabilities();
static String Appium_Node_Path = “C:\Program Files\nodejs\node.exe”;//That is my patch, change it to your path
static String Appium_JS_Path = “C:\node_modules\appium\build\lib\main.js”; //That is my patch, change it to your path
cap.setCapability(“deviceName”, deviceName);
cap.setCapability(“udid”, udid);
cap.setCapability(“url”, url);
cap.setCapability("appPackage", "your package");
cap.setCapability("appActivity", "your activity");
cap.setCapability(MobileCapabilityType.NO_RESET, true);
AppiumDriverLocalService service;
service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder().
usingPort(4723).usingDriverExecutable(new File(Appium_Node_Path)).
withAppiumJS(new File(Appium_JS_Path))
.withArgument(GeneralServerFlag.RELAXED_SECURITY)
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withArgument(GeneralServerFlag.LOG_LEVEL, "error")
.withCapabilities(cap));
service.start();
Log.info("Appium started ......");
Thread.sleep(10000);
driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), cap);
And make another one just like that with 1 change: URL: with diff port,
also using testng.xml for each device,
Works great !