You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, seleniumRobot quits driver when test ends. But in case driver is stuck (e.g: SocketTimeoutException), this method won't work.
A solution is to get driver + browser PID at the start and end of the test and force to kill these processes if they remain after clean quit
By default, seleniumRobot quits driver when test ends. But in case driver is stuck (e.g: SocketTimeoutException), this method won't work.
A solution is to get driver + browser PID at the start and end of the test and force to kill these processes if they remain after clean quit
Here is an example for windows / linux: https://stackoverflow.com/questions/10752512/get-pid-of-browser-launched-by-selenium
private void getDriverPid() { final String jvmName = ManagementFactory.getRuntimeMXBean().getName(); final int index = jvmName.indexOf('@'); if(index > 1) { try { String processId = Long.toString(Long.parseLong(jvmName.substring(0, index))); Scanner scan = new Scanner(Runtime.getRuntime().exec("pgrep -P "+ processId).getInputStream()); // Scanner scan = new Scanner(Runtime.getRuntime().exec("wmic process where (ParentProcessId="+ processId +") get Caption,ProcessId").getInputStream()); scan.useDelimiter("\\A"); String childProcessIds = scan.hasNext() ? scan.next() : ""; List<String> chromeDrivers = new ArrayList<String>(); String[] splited = childProcessIds.split("\\s+"); for(int i =0 ; i<splited.length; i = i+2){ if("chromedriver.exe".equalsIgnoreCase(splited[i])){ chromeDrivers.add(splited[i+1]); } } scan.close(); } catch (Exception e) { } } }
The text was updated successfully, but these errors were encountered: