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();
        }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM