杀掉windows的浏览器进程
引入包
import org.openqa.selenium.os.WindowsUtils;
方法:
WindowsUtils.killByName("firefox.exe");
完整代码:
import org.openqa.selenium.os.WindowsUtils;
import org.testng.annotations.Test;
public class KillBrowserThread {
@Test
public void killThread() {
//杀掉windows进程中的Firefox浏览器进程,关闭所有Firefox浏览器窗口
WindowsUtils.killByName("firefox.exe");
//关闭所有chrome浏览器
WindowsUtils.killByName("chrome.exe");
//关闭所有IE浏览器
WindowsUtils.killByName("iexplore.exe");
}
}