码迷,mamicode.com
首页 > 移动开发 > 详细

Appium-操作事件

时间:2020-04-08 17:33:56      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:时间   自动   element   另一个   tin   结束   启动   star   duration   

1、swip滑动事件

从一个坐标位置滑动到另一个坐标位置,只能是两个点之间的滑动

  方法:swipe(start_x, start_y, end_x, end_y, duration=None)
  参数:
      1.start_x:起点X轴坐标
      2.start_y:起点Y轴坐标
      3.end_x:  终点X轴坐标
      4.end_y,: 终点Y轴坐标
      5.duration: 滑动这个操作一共持续的时间长度,单位:ms
实现:
driver.swipe(31,900,31,195,duration=None)    从(31.,900)滑到(31,195)

2、scroll滑动事件
   从一个元素滑动到另一个元素,直到页面自动停止

方法:scroll(origin_el, destination_el)
  参数:
      1.origin_el:滑动开始的元素
      2.destination_el:滑动结束的元素
实现:由应用滑动到蓝牙
   origin_el=driver.find_element_by_xpath("//*[contains(@text,‘应用‘)]")
    destination_el=driver.find_element_by_xpath("//*[contains(@text,‘蓝牙‘)]")
      driver.scroll(origin_el, destination_el)

3、drag拖拽事件
从一个元素滑动到另一个元素,第二个元素替代第一个元素原本屏幕上的位置
  方法:drag_and_drop(origin_el, destination_el)
  参数:
      1.origin_el:滑动开始的元素
      2.destination_el:滑动结束的元素
实现:
由应用滑动到蓝牙
   origin_el=driver.find_element_by_xpath("//*[contains(@text,‘应用‘)]")
   destination_el=driver.find_element_by_xpath("//*[contains(@text,‘蓝牙‘)]")
      driver.drag_and_drop(origin_el, destination_el)
4、应用置于后台事件
    APP放置后台,模拟热启动
    方法:background_app(seconds)
    参数:
        1.seconds:停留在后台的时间,单位:秒
  实现  设置置于后台5s在展示在前台:driver.background_app(5)
 
 

Appium-操作事件

标签:时间   自动   element   另一个   tin   结束   启动   star   duration   

原文地址:https://www.cnblogs.com/xwxxh/p/12661303.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!