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

猜你喜欢

转载自www.cnblogs.com/felixer/p/9019448.html
今日推荐