#调用方式
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. js动画之简单运动二

    透明度的变化 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...

  2. Linux Centos7下安装Python

    1.查看是否已经安装Python Centos7默认安装了python2.7.5 因为一些命令要用它比如yum 它使用的是python2.7.5. 使用python -V命令查看一下是否安装Pytho ...

  3. bigworld源码分析(5)——BaseApp分析

    BaseApp负载部分,核心代码缺失...网上的源码中都找不到,暂时没办法分析其核心内容,很遗憾,继续寻找吧,等找到了,再继续自己的分析.

  4. PAT (Basic Level) Practise:1038. 统计同成绩学生

    [题目链接] 本题要求读入N名学生的成绩,将获得某一给定分数的学生人数输出. 输入格式: 输入在第1行给出不超过105的正整数N,即学生总人数.随后1行给出N名学生的百分制整数成绩,中间以空格分隔.最 ...

  5. 腾讯优测-优社区干货精选 | android开发在路上:少去踩坑,多走捷径(下)

    文/腾讯公司 陈江峰 优测小优有话说: android开发的坑自然是不少,不想掉坑快来优测优社区~ 6.Android APP开发中其它需要提醒的问题 android4.4在UI线程无法进行网络操作. ...

  6. UVa 10129单词(欧拉回路)

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  7. UIApplication的使用

    //// UIApplication的使用//  IOS笔记////  Created by **** on ****.//  Copyright © 2013年 ***. All rights re ...

  8. IncDec Sequence

    题目链接 http://www.lydsy.com/JudgeOnline/problem.php?id=3043[题目描述]给定一个长度为 n 的数列{a1,a2...an},每次可以选择一个区间[ ...

  9. Learning to write a compiler

    http://stackoverflow.com/questions/1669/learning-to-write-a-compiler?rq=1 Big List of Resources: A N ...

  10. Deleting backup_label on restore will corrupt your database!

    The quick summary of this issue is that the backup_label file is an integral part of your database c ...