Appium + java截图方法

    public static void takeScreenShot(AndroidDriver<WebElement> driver)
    {  
       File screenShotFile = driver.getScreenshotAs(OutputType.FILE);  
       try {   
          FileUtils.copyFile(screenShotFile, new File("D:\\AutoScreenCapture\\" + getCurrentDateTime()+ ".jpg"));  
          } 
       catch (IOException e) {e.printStackTrace();}  
    } 
    public static String getCurrentDateTime(){
       SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd_HHmmss");//设置日期格式
       return df.format(new Date());
    }

 

方法引用:

 

takeScreen.takeScreenShot(driver);

posted @ 2018-05-10 14:26  隐身即无敌  阅读(282)  评论(0编辑  收藏  举报