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})
    ###这个比较靠谱,速度快,可以自定义滑动距离,还可以在某个元素上滑动,缺点:如果是元素的话,滑动前会点击一次,若元素有点击事件的话比较麻烦


     
  • 相关阅读:
    梯度消失和梯度爆炸
    BN的作用与使用过程
    百面机器学习笔记(二)
    正则表达式
    CSS Sprite
    事件绑定
    拖拽
    oncontextmenu
    鼠标跟随
    鼠标事件
  • 原文地址:https://www.cnblogs.com/drewgg/p/10044490.html
Copyright © 2011-2022 走看看