use of com.seleniumtests.util.osutility.OSUtility in project seleniumRobot by bhecquet.
the class BrowserInfo method getProgramPid.
/**
* get
* @return
*/
public List<Long> getProgramPid(String programName, List<Long> existingPids) {
final String jvmName = ManagementFactory.getRuntimeMXBean().getName();
final int index = jvmName.indexOf('@');
OSUtility osUtility = OSUtilityFactory.getInstance();
if (index == 0) {
return new ArrayList<>();
}
try {
String processId = Long.toString(Long.parseLong(jvmName.substring(0, index)));
return osUtility.getChildProcessPid(Long.parseLong(processId), programName + osUtility.getProgramExtension(), existingPids);
} catch (Exception e) {
logger.warn("could not get driver pid", e);
return new ArrayList<>();
}
}
use of com.seleniumtests.util.osutility.OSUtility in project seleniumRobot by bhecquet.
the class BrowserInfo method getAllBrowserSubprocessPids.
/**
* Get the list of pids for the browser launched by driver and all subprocess created by browser
* @param driverPid
* @return
*/
public List<Long> getAllBrowserSubprocessPids(List<Long> driverPids) {
OSUtility osUtility = OSUtilityFactory.getInstance();
List<Long> allPids = new ArrayList<>(driverPids);
try {
for (Long driverPid : driverPids) {
List<Long> browserPids = osUtility.getChildProcessPid(driverPid, null, new ArrayList<>());
allPids.addAll(browserPids);
for (Long browserPid : browserPids) {
List<Long> subBrowserPids = osUtility.getChildProcessPid(browserPid, null, new ArrayList<>());
allPids.addAll(subBrowserPids);
}
}
return allPids;
} catch (IOException e) {
return new ArrayList<>();
}
}
Aggregations