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

  • 相关阅读:
    POJ 3126 Prime Path
    POJ 2429 GCD & LCM Inverse
    POJ 2395 Out of Hay
    【Codeforces 105D】 Bag of mice
    【POJ 3071】 Football
    【POJ 2096】 Collecting Bugs
    【CQOI 2009】 余数之和
    【Codeforces 258E】 Devu and Flowers
    【SDOI 2010】 古代猪文
    【BZOJ 2982】 combination
  • 原文地址:https://www.cnblogs.com/strggle/p/6527322.html
Copyright © 2011-2022 走看看