After I switch to a new window and complete the task, I want to close that new window and switch to the old window,
so here i written like code:
// P
I've also tried
1)driver.close();
2)driver.quit();
apparently, these methods don't work as expected!(not saying it don't work though) I've even tried making the driver class singleton and it didn't help me with running test cases parallel.so it was also not the optimal solution.finally, i came up creating a separate class to run a bat file.which the bat file contains commands of grouping all the chrome driver process and all the child processes of it.and from the java class I've executed it using Runtime.
The class file that runs the bat file
public class KillChromeDrivers {
public static void main(String args[]) {
try {
Runtime.getRuntime().exec("cmd /c start E:\\Work_Folder\\SelTools\\KillDrivers.bat");
//Runtime.getRuntime().exec()
} catch (Exception ex) {
}
}
}
The command that you have to put in the [ .bat ] file
taskkill /IM "chromedriver.exe" /T /F