最近一直在尝试Appnium实现Android手机自动化测试,一直一直卡在一个点上,那就是手势密码,因为所测应用的手势密码使用的不是单个的imageview实现的手势密码解锁窗,所以只能靠坐标点来定位。在网上看到的资料,使用python写的解锁手势密码的Appnium代码如下形式:

         action = TouchAction(driver)
unlock = action.press(x=240, y=915).wait(ms=100)\
.move_to(x=480, y=0).wait(ms=100)\
.move_to(x=480, y=0).wait(ms=100)\
.release()
print unlock
unlock.perform()

但是,为什么自己实现的时候总是报错:

The coordinates provided to an interactions operation are invalid.

这段代码里面有俩个坑,呃,关键点:

1.press方法中的坐标为绝对坐标,move_to方法中的坐标都是相对坐标,具体来说第一个move_to中的坐标相对于press方法中的坐标,第二个move_to方法中的坐标相对于第一个move_to方法中的坐标。

2.wait是必须的:这里ms表示为毫秒,ms=100就是等待100毫秒。不用的话太快会出错

这俩关键点卡了我一天。。。写出来给大家看看,可能也会出这种问题吧

Appnium+python实现手势密码为什么总是报错的更多相关文章

  1. python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?

    python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...

  2. 【Devops】【docker】【CI/CD】Jenkins自动安装JDK需要提供Oracle的账号密码,否则报错:Unable ro auto-install JDK until the license is accepted

    Jenkins自动安装JDK需要提供Oracle的账号密码,否则报错:Unable ro auto-install JDK  until the  license is accepted 解决方法: ...

  3. 记一次用python 的ConfigParser读取配置文件编码报错

    记一次用python 的ConfigParser读取配置文件编码报错 ...... raise MissingSectionHeaderError(fpname, lineno, line)Confi ...

  4. Python“Non-ASCII character 'xe5' in file”报错问题(转)

    今天在编译一个Python程序的时候,一直出现"Non-ASCII character 'xe5' in file"报错问题 SyntaxError: Non-ASCII char ...

  5. Mysql修改root用户密码 For Mac 报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    环境 Mysql版本:5.7.12 操作系统:OSX 10.11 安装文件:.dmg文件 MySQL:mysql-5.7.12-osx10.11-x86_64.dmg(注意5.7跟之前的字段有些不同, ...

  6. python 基础之pickle 与json 报错问题解决方案

    Python 基础之pickle与json 有没有在搞pickle与json在进行数据储存的时候老是报错,这个有些让人烦恼,在之前有一篇介绍过它们的基本用法以及在使用过长中避免一些坑,但是今天在把对象 ...

  7. python+Django+test 测试数据库生成报错

    前提: 使用Django自带的test进行单元测试. 问题描述: 运行:python manage.py test,报错,出现数据库乱码的现象,报错如下: Creating test database ...

  8. Python“Non-ASCII character 'xe5' in file”报错问题

    今天在编译一个Python程序的时候,一直出现“Non-ASCII character 'xe5' in file”报错问题 SyntaxError: Non-ASCII character '\xe ...

  9. MySQL用户密码过期登陆报错ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

    今天接到主从复制失败告警,查看MySQL,发现MySQL能够登陆但是执行命令报错, ERROR 1820 (HY000): You must reset your password using ALT ...

随机推荐

  1. [Javascript] Array methods in depth - slice

    Array slice creates a shallow copy of an array. In this lesson we cover, in detail, exactly what a ' ...

  2. logcat使用

    做android有些日子了,只是对主要的logcat的具体使用方法还是非常模糊,今天有空,学习一下. logcat能够在adb中使用,也能够直接在命令行下使用. logcat [options] [f ...

  3. unicode下各种类型转换,CString,string,char*,int,char[]

    把最近用到的各种unicode下类型转换总结了一下,今后遇到其他的再补充: 1.string转CString string a=”abc”; CString str=CString(a.c_str() ...

  4. Target runtime Apache Tomcat v6.0 is not defined. phyy Unknown Faceted Project Problem

    Description Resource Path Location TypeTarget runtime Apache Tomcat v6.0 is not defined. phyy Unknow ...

  5. Chapter 4. Using the Gradle Command-Line 使用gradle命令行

    This chapter introduces the basics of the Gradle command-line. You run a build using the gradle comm ...

  6. android的task任务栈

    转自http://blog.csdn.net/liuhe688/article/details/6761337 古人學問無遺力,少壯工夫老始成.紙上得來終覺淺,絕知此事要躬行.南宋.陸遊<冬夜讀 ...

  7. Win32 WriteFile and ReadFile

    HANDLE WINAPI CreateFile( __in LPCTSTR lpFileName, // 文件路径 __in DWORD dwDesiredAccess, // 访问权限,GENER ...

  8. css动画+照片清晰度动画

    源代码: <!DOCTYPE html><html><head> <title>donghua</title> <meta chars ...

  9. Win7启动修复MBR(Win7+Linux删除Linux后进入grub rescue的情况)

    事因:我的笔记本原先同时安装了Win7+Linux,昨天发现硬盘实在不够用(才60G,虽然还有个500G的移动硬盘),就想把里面的Ubuntu格了.都是用虚拟机做测试的多.后来就格了Ubuntu所在的 ...

  10. ORACLE SQL单行函数(三)【weber出品必属精品】

    16.L:代表本地货币符,这个和区域有关.这个时候我们想来显示一下人民币的符号:¥ $ vi .bash_profile ---写入如下内容: export NLS_LANG='SIMPLIFIED ...