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 < ...
 
随机推荐
- android 环境变量配置,以及sdcard配置
			
第一步,打开环境变量配置窗口.右击计算机,属性-高级系统设置-环境变量. 第二步,添加android系统环境变量.在系统变量下,选择path,点击编辑,然后在最前面输入android sdk开发工具, ...
 - 【String】String.format(format,args...)的使用解析
			
String.format(format,args...)的使用解析 使用kotlin 中使用示例 ================================================== ...
 - Mac--安装kubernetes并运行echoserver
			
安装minikube curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.15.0/minikube-darwi ...
 - linxu下的shell脚本加密,shell生成二机制可执行文件
			
再安全的加密也抵不过逆向,斗智斗勇吧,持续加密持续破解 1.简单的加密:gzexe file.sh 2.使用shc加密:下载地址:http://www.datsi.fi.upm.es/~frosal/ ...
 - flask-limiter限制单个IP访问的频率和次数
			
Flask-Limiter provides rate limiting features to flask routes. It has support for a configurable bac ...
 - 向C#的选项卡中添加自定义窗体
			
一.自定义窗体的搭建 这个比较简单,添加一个WinForm窗体就行了,设置一个名字EditPanel,然后在窗体上画需要的控件. 二.将自定义窗体添加到选项卡 // 新建窗体加入到选项卡中 EditP ...
 - 浅谈BloomFilter【下】用Java实现BloomFilter
			
通过前一篇文章的学习,对于 BloomFilter 的概念和原理.以及误报率等计算方法都一个理性的认识了. 在这里,我们将用 Java'实现一个简单的 BloomFilter . package pr ...
 - vue2.0  自定义过滤器(filter)实例
			
一.过滤器简介 (1)过滤器创建 过滤器的本质 是一个有参数 有返回值的方法 new Vue({ filters:{ myCurrency:function(myInput){ return 处理后的 ...
 - Android URL中文处理
			
不多说,贴上代码.大家都明确 import java.io.File; import android.net.Uri; public class Transition { /** * @param u ...
 - 解决最新版的ADT没有NDK选项的问题
			
最新版的ADT不显示NDK,解决方法有两种,第一种方法在线重装一下 这种方法有一个问题就是,google的东西我们经常不能访问,解决方法可以参考http://blog.csdn.net/shi_wei ...