zoukankan      html  css  js  c++  java
  • appium + Python + iOS 滑屏方法(appium版本大于1.5)

    之前一直在搞android的自动化,滑动操作一直都用swipe(),比如:

    he1 = int(dr.get_window_size()['height'] * 0.8)
    he2 = int(dr.get_window_size()['height'] * 0.2)
    wd1 = int(dr.get_window_size()['width'] * 0.2)
    wd2 = int(dr.get_window_size()['width'] * 0.2)
    dr.swipe(wd1, he1, wd2, he2, 1100) 
     
    iOS想上滑翻页时同样的swipe无效报错,网上找了半天最终放弃了swipe,以下是几个比较靠谱的滑动方法:
    第一种方式:
    dr.execute_script('mobile: scroll', {'direction': 'down'})
    ###这种方式不仅滑动两次,还是反的,down是向上滑动,速度较慢

    第二种方式:
    dr.execute_script('mobile: swipe', {'direction': 'up'})
    ###向上滑动一屏,速度较快,但不能自定义滑动距离

    第三种方式:
    dr.execute_script("mobile:dragFromToForDuration", {"duration": 0.5, "element": None, "fromX": wd1, "fromY": he1, "toX": wd2, "toY": he2})
    ###这个比较靠谱,速度快,可以自定义滑动距离,还可以在某个元素上滑动,缺点:如果是元素的话,滑动前会点击一次,若元素有点击事件的话比较麻烦


     
  • 相关阅读:
    Week14
    带你一文读懂Batch Normalization
    019_04简易相机
    019_03camera的调用
    019_02视频播放之VideoView
    019_01播放视频之SurfaceView
    018_04音效播放之MediaPlayer与SoundPool
    018_03简易美图
    018_02图片水印
    018_01图片特效
  • 原文地址:https://www.cnblogs.com/drewgg/p/10044490.html
Copyright © 2011-2022 走看看