selenium杀掉浏览器进程方法

时间:2023-03-09 22:23:56
selenium杀掉浏览器进程方法

* 杀掉浏览器进程
      */
     public static void operateWindowsProcess(){
         WindowsUtils.tryToKillByName("chrome.exe");
     }

        //将浏览器窗口截屏,调用getScreenshotAs方法把当前浏览器截图,保存
        File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
        try {
            //把File对象转换为一个保存在C盘下testing目录中名为test.png的图片文件
            FileUtils.copyFile(scrFile, new File("d:\\testing\\test.png"));
        } catch (IOException e) {
            e.printStackTrace();
        }