#调用方式
roll_ele("ID","ele_id","7","up",3)#将控件分为7格,从底部倒数第二格向上滑动3格
#滑动控件的方法
def roll_ele(id,ele_id,size,direct,rollsize=1):
"""
参数id为定位方式,eled_id为具体控件的id或xpath等,size为需要把该控件分成几格,direct为滑动方向,up或down(上或下),rollsize为要滑动几格,该参数取值范围为(1,size-2)
"""
#以下是滑动该单据详情数据---------------------------------------------------------------------------- ele_ = Element(id,ele_id) #Element为自己包装的一个定位控件的类
start_loc = ele_.get_location_start() #获取控件的起点坐标,get_location_start()为自己写的的一个获取控件的起点坐标和结束坐标的方法,appium直接为element.location,返回的类型为dict,{'x':520,'y':1230} size_ele = ele_.get_ele_size() #获取控件的大小,get_ele_size()为自己写的一个获取控件大小的方法,appium直接为element.size,返回的类型为dict,如{'height':589,'width':270} #控件上方中心的坐标
ele_start = []
ele_start.append(float(start_loc['x'])+float(size_ele['width'])/2)
ele_start.append(float(start_loc['y'])) #控件下方中心的坐标
ele_end = []
ele_end.append(float(start_loc['x'])+float(size_ele['width'])/2)
ele_end.append(float(start_loc['y'])+float(size_ele['height'])) #控件列有size行,每次滑动1/size格,即size_ele['height']/size个长度
per_height = float(size_ele['height'])/size #每格的高度 #若为up,则滑动时,每次从倒数第二格坐标,滑动到上面rollsize格的坐标(因为直接从控件最底部滑动无法滑动,会失败);其他则都向下滑动
if direct=='up':#swipe_to为自己包装的driver.swipe()方法
swipe_to(ele_end[0],ele_end[1]-per_height,ele_end[0],ele_end[1]-per_height-rollsize*per_height,1000)
else:
swipe_to(ele_start[0],ele_start[1]+per_height,ele_start[0],ele_start[1]+per_height+rollsize*per_height,1000)
time.sleep(1)

appium+python:自己写的一个滑动控件的方式的更多相关文章

  1. 自己写的一个分页控件类(WinForm)

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; u ...

  2. RecyclerView 加入一个滑动控件bug处理 GridView只显示第一行

    如果RecyclerView 多样式布局,比如要加入一个展示多个图看的需求.自然想到用gridview给嵌套一下. 想法当然是可以的,但是发现,嵌套出来的效果是,gridview只显示一行. 想想原因 ...

  3. appium ios 相对坐标点击和控件滑动操作

    环境: 系统:ios 10.13.6 (17G12034) appium:1.14.0 xcode:10.1 iphone:iphone7 12.4 在尝试使用driver.tap([(a,b)],5 ...

  4. 基于七牛Python SDK写的一个批量下载脚本

    前言 上一篇基于七牛Python SDK写的一个同步脚本所写的脚本只支持上传,不支持文件下载. 虽然这个需求不太强烈,但有可能有人(在备份.迁移时)需要,而官方有没提供对应的工具,所以我就把这个功能也 ...

  5. Appium Android Bootstrap源码分析之控件AndroidElement

    通过上一篇文章<Appium Android Bootstrap源码分析之简介>我们对bootstrap的定义以及其在appium和uiautomator处于一个什么样的位置有了一个初步的 ...

  6. Python实例讲解 -- wxpython 基本的控件 (按钮)

    使用按钮工作 在wxPython 中有很多不同类型的按钮.这一节,我们将讨论文本按钮.位图按钮.开关按钮(toggle buttons )和通用(generic )按钮. 如何生成一个按钮? 在第一部 ...

  7. 基于webview的选择滑动控件(PC和wap版)

    有了webview,大家开发ios或者安卓的app就方便很多啦. 第一可以增量更新: 第二webview可以同时兼容ios和安卓,减少开发量哦. --------------------------- ...

  8. Appium移动自动化测试-----(八)定位控件

    appium 通过 uiautomatorviewer.bat 工具来查看控件的属性.该工具位于 Android SDK 的 /tools/bin/ 目录下. id 定位 通过uiautomatorv ...

  9. 使用 ViewPager 和 RadioGroup 封装的一个导航控件

    import android.animation.ObjectAnimator; import android.content.Context; import android.graphics.dra ...

随机推荐

  1. Apache代理Tomcat实现session共享构建网上商城系统

    一.环境介绍 二.安装配置后端服务器 三.安装配置前端服务器 四.配置Tomcat服务器实现session共享 五.构建网上商城系统 一.环境介绍 系统版本:CentOS 6.4_x86_64 Mys ...

  2. C语言获得数组长度的函数

    <转自百度知道> 1.c语言中,定义数组后可以用sizeof命令获得数组的长度(可容纳元素个数). 例如: int data[4]; int length; length=sizeof(d ...

  3. Matcher.group

    Exception in thread "main" java.lang.IllegalStateException: No match found at java.util.re ...

  4. C++ Daily 《4》----一个简单的 int to string 的方法

    经常会在项目中用到 int to string, 之前一般用C语言的 sprintf, 发现C++ 中的 ostringstream 可以轻松完成这个任务. #include <iostream ...

  5. css3 倒影

    说起倒影效果,在传统网页中,我们只能使用photoshop进行事先将倒影设计好,然后导入到网页中,这样不但耗费资源,也阻碍了开发的效率.而 css3新增了Reflections板块,css  Refl ...

  6. cocos2dx 3.0 之 lua 创建类

    利用3.0里面封装好的模板类来写,不罗嗦,直接上例子(消除星星小游戏中 星星类) require "extern" StarSprite = class("StarSpr ...

  7. 12-2 mysql 查询

    老师提纲 1. create database test2. drop database test3. create table info( code int primary key, name va ...

  8. xpcall 安全调用

    -- xpall (调用函数f, 错误函数fe[, 参数]) function fun(a,b)   -- 这里的参数没什么实际作用,就是展示下用法    return a / bend -- xpc ...

  9. java取整和java四舍五入方法 转自董俊杰

    import java.math.BigDecimal; import java.text.DecimalFormat; public class TestGetInt{ public static ...

  10. Couldn't open file on client side, trying server side 错误解决

    09-09 09:43:21.651: D/MediaPlayer(3340): Couldn't open file on client side, trying server side09-09 ...