RobotFramework:App九宫格滑动解锁
转自:http://blog.csdn.net/codekxx/article/details/50577381
手势密码在很多手机应用都会运到,手势密码都要求至少连接4个点,但AppiumLibrary并没有提供对应的关键字,本人尝试连续使用Swipe关键字两次解决该问题,为什么要用两次呢?因为Swipe的参数只是起点和终点,如果直接给出手势密码的起点和终点,则会忽略中间的点。
手机QQ手势密码如下:

AppiumLibrary它是开源的,就直接去修改其源代码。
于是,去到AppiumLibrary安装的文件夹,默认安装路径为:C:\Python27\Lib\site-packages\AppiumLibrary\keywords),再到keywords目录中找到_touch.py文件,就是它了。
给这个文件的类_TouchKeywords加上一个方法nine_palace_unlock,具体代码如下:
def nine_palace_unlock(self, locator):
"""nine palace"""
driver = self._current_application()
action = TouchAction(driver)
lock_pattern = driver.find_element_by_xpath(locator) x = lock_pattern.location.get('x')
y = lock_pattern.location.get('y')
width = lock_pattern.size.get('width')
height = lock_pattern.size.get('height') offset = width / 6
p11 = int(x + width / 6), int(y + height / 6)
p12 = int(x + width / 2), int(y + height / 6)
p13 = int(x + width - offset), int(y + height / 6)
p21 = int(x + width / 6), int(y + height / 2)
p22 = int(x + width / 2), int(y + height / 2)
p23 = int(x + width - offset), int(y + height / 2)
p31 = int(x + width / 6), int(y + height - offset)
p32 = int(x + width / 2), int(y + height - offset)
p33 = int(x + width - offset), int(y + height - offset) print(p11,p12,p13)
print(p21,p22,p23)
print(p31,p32,p33) p2 = p12[0] - p11[0]
print(p2)
sleep(3) action.press(x=p11[0],y=p11[1]).move_to(x=p2,y=0).wait(1000).move_to(x=p2,y=0).wait(1000).\
move_to(x=-p2,y=p2).wait(1000).move_to(x=-p2,y=p2).wait(1000).release().wait(1000).perform()
代码如下:

代码如下:
*** Settings ***
Suite Setup
Suite Teardown
Library AppiumLibrary *** Variables *** *** Test Cases *** 手机QQ
Open Application http://localhost:4723/wd/hub platformName=Android platformVersion=19 deviceName=127.0.0.1:21503 app=${CURDIR}${/}QQ_794.apk appPackage=com.tencent.mobileqq
... appActivity=com.tencent.mobileqq.activity.SplashActivity unicodeKeyboard=True resetKeyboard=True
Wait Until Page Contains Element xpath=//android.widget.LinearLayout[@resource-id=\"com.tencent.mobileqq:id/name\"]/android.view.View[5] #等待手机QQ打开完成
Nine Palace Unlock //android.widget.LinearLayout[@resource-id=\"com.tencent.mobileqq:id/name\"]/android.view.View[5]
[Teardown] Close All Applications *** Keywords ***
RobotFramework:App九宫格滑动解锁的更多相关文章
- APP九宫格滑动解锁的处理
写手机自动化测试脚本关于APP九宫格滑动解锁方面采用了appium API 之 TouchAction 操作. 先是用uiautomatorviewer.bat查询APP元素坐标: 手工计算九宫格每个 ...
- Appium九宫格滑动解锁
1.适配各种机型,首先获取整个解锁元素的坐标 2.代码实现 WebElement lockPattern = driver.findElement(By.id("com.android.se ...
- APP自动化 -- 滑动解锁、滑动验证
一.解锁 1.代码 2.效果 1)执行效果 2)点位效果
- uiautomator2 实现App九宫格解锁
App九宫格解锁 之前在testerhome社区看见codeskyblue大佬写过一种方法,但是这种办法存在一个弊端,那就是多个点的坐标是写死的,也就是说要是换了部手机,九宫格解锁就行不通了,于是就想 ...
- Swift: 打造滑动解锁文字动画
原文:Swift: 打造滑动解锁文字动画 最近木事,找出来玩了玩facebook的paper.到处都是那个"slide to unlock your phone"的效果啊.忽闪忽闪 ...
- hiho_1054_滑动解锁
题目大意 智能手机九点屏幕滑动解锁,如果给出某些连接线段,求出经过所有给出线段的合法的滑动解锁手势的总数.题目链接: 滑动解锁 题目分析 首先,尝试求解没有给定线段情况下,所有合法的路径的总数.可以使 ...
- hihocoder#1054 : 滑动解锁(深度优先搜索)
描述 滑动解锁是智能手机一项常用的功能.你需要在3x3的点阵上,从任意一个点开始,反复移动到一个尚未经过的"相邻"的点.这些划过的点所组成的有向折线,如果与预设的折线在图案.方向上 ...
- Selenium模拟JQuery滑动解锁
滑动解锁一直做UI自动化的难点之一,我补一篇滑动解锁的例子,希望能给初做Web UI自动化测试的同学一些思路. 首先先看个例子. https://www.helloweba.com/demo/2017 ...
- hihocoder 1054 滑动解锁 dfs
详细分析见滑动解锁分析 AC代码 #include <cstdio> #include <cmath> #include <cctype> #include < ...
随机推荐
- Java I/O概述
Java的I/O通过java.io包下的类.接口来支持.在java.io包下主要包括输入.输出两种IO流,每种输入.输出流又可分为字符流.字节流两大类. 字符流以字符为单位处理输入.输出操作,字节流以 ...
- MySQL---笔记之视图的使用详解
什么是视图 视图是从一个或多个表中导出来的表,是一种虚拟存在的表. 视图就像一个窗口,通过这个窗口可以看到系统专门提供的数据. 这样,用户可以不用看到整个数据库中的数据,而之关心对自己有用的数据. ...
- 王立平--GUI与GUILayout的差别
GUI.Button (new Rect(0,0,5,5,"哈哈"); GUILayout.Button ("heheh"); 1.以上代码都是现实一个butt ...
- HDU 5289 Assignment(多校联合第一场1002)
Assignment Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total ...
- Intel processor brand names-Xeon,Core,Pentium,Celeron----Pentium
http://en.wikipedia.org/wiki/Pentium Pentium From Wikipedia, the free encyclopedia This article ...
- CPU维修技术
中央处理单元(Central Process Unit)简称CPU,是电脑的核心部件,负责处理和运算电脑内部所有数据.因其在电脑中的地位相当重要,所以一旦发生故障就会造成很严重的后果. [技术66]开 ...
- testng 工程报错java.net.SocketException
报错如下: java.net.SocketException: Software caused connection abort: socket write error at java.net.Soc ...
- appium 查错
很高兴最近论坛用appium的人多了不少,但也有不少由于不了解appium导致出现错误后不知道从何下手.这里根据我的个人经验给出一个简单的查错指南,不保证能解决所有错误,但至少让你知道你应该朝哪个方向 ...
- 基于ADB框架Robotium跨进程操作
转自:http://blog.csdn.net/qingchunjun/article/details/42580937 2015年2月3日更新: 有些朋友在用真机尝试本方法时,抛出了InputStr ...
- jvm 命令
jps jps主要用来输出JVM中运行的进程状态信息.语法格式如下: jps [options] [hostid] 如果不指定hostid就默认为当前主机或服务器. -q 不输出类名.Jar名和传入 ...