zoukankan      html  css  js  c++  java
  • appium 截屏和滑动功能

    以下代码放进主函数就可用

    //7.滑动截屏 
    // File screen = driver.getScreenshotAs(OutputType.FILE);
    // File screenFile = new File("d:\screen.png");
    // try {
    // FileUtils.copyFile(screen, screenFile); //commons-io-2.0.1.jar中的api
    // } catch (IOException e) {
    // e.printStackTrace();
    // }
    //
    //滑动屏幕
    //定义一个文件
    File screen1=driver.getScreenshotAs(OutputType.FILE);
    //把截图编程图片
    BufferedImage bos=ImageIO.read(screen1);
    //获取不同手机屏幕的宽高
    int width=bos.getWidth();
    int heigth=bos.getHeight();
    //1.往右边
    driver.swipe(heigth/2, width*9/10, width*1/10, heigth/2, 1000);
    Thread.sleep(3000);
    driver.swipe(heigth/2, width*9/10, width*1/10, heigth/2, 1000);
    Thread.sleep(3000);
    //2.往左边
    driver.swipe(width*1/10, heigth/2, width*9/10, heigth/2, 1000);
    Thread.sleep(3000);
    driver.swipe(width*1/10, heigth/2, width*9/10, heigth/2, 1000);
    Thread.sleep(3000);
    //3.往上滑
    driver.swipe(width/2,heigth*9/10, width/2, heigth*1/10, 1000);
    Thread.sleep(3000);
    driver.swipe(width/2,heigth*9/10, width/2, heigth*1/10, 1000);
    Thread.sleep(3000);
    //4.往下滑
    driver.swipe(width/2,heigth*1/10, width/2, heigth*9/10, 1000);
    Thread.sleep(3000);
    driver.swipe(width/2,heigth*1/10, width/2, heigth*9/10, 1000);
    Thread.sleep(3000);

  • 相关阅读:
    bzoj 1040: [ZJOI2008]骑士
    CF Playrix Codescapes Cup Problems Analysis
    C++ 指针[转+原创]
    高斯消元
    NOIP模拟
    线段树合并
    After ZJOI2017 day2
    ZJOI 2017 day2 4.27
    ZJOI 2017 二试 day1 4.26
    ZJOI 2017 二试 day0
  • 原文地址:https://www.cnblogs.com/strggle/p/6527322.html
Copyright © 2011-2022 走看看