@Aleksei
I am using 1.7.2 and tried using java executor service to create drivers concurrently on different ports. has anyone done this sucessfully?
created
Aug '18
last reply
Aug '18
- 5
replies
- 212
views
- 2
users
- 1
like
@Aleksei
I am using 1.7.2 and tried using java executor service to create drivers concurrently on different ports. has anyone done this sucessfully?
i do not understand you.
@Aleksei Thanks
OK, I had an error in the callable interface implementation which i corrected and works fine now.
what I did:
created a class which implements callable interface. I have port and desired capability as data type in this class.
Created an executor service with thread pool size = number of attched devices.
and then invoke submit on executor service.
ExecutorService es = Executors.newFixedThreadPool(2);
Future<AndroidDriver> sc1 = es.submit(new InvokeDriverInParallel.CreateDriverConcurrently(4725,androidCapabilities));
Future<AndroidDriver> sc2 = es.submit(new InvokeDriverInParallel.CreateDriverConcurrently(4727,androidCapabilitiesTwo));
try {
System.out.println(sc1.get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
try {
System.out.println(sc2.get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
@Venkatesh mine code is old style. i am starting appium server mysef:
// server 1
List list = new ArrayList<String>();
list.add("appium");
list.add("--log-level");
list.add("error");
list.add("--port");
list.add(appiumServer1_PortPublic);
list.add("--bootstrap-port");
list.add(String.valueOf(Integer.parseInt(appiumServer1_PortPublic)+1000));
list.add("--command-timeout");
list.add("180");
list.add("--session-override");
list.add("--log-timestamp");
// create the process builder
try {
ProcessBuilder pb1 = new ProcessBuilder(list);
//print inputStream to console
pb1.redirectErrorStream(true);
pb1.redirectOutput(ProcessBuilder.Redirect.INHERIT);
appium_Process = pb1.start();
} catch (Exception e) {
e.printStackTrace();
}
and after this opening driver later against ‘appiumServer1_PortPublic’ port. Server2 and driver2 is similar.