转自: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九宫格滑动解锁的更多相关文章

  1. APP九宫格滑动解锁的处理

    写手机自动化测试脚本关于APP九宫格滑动解锁方面采用了appium API 之 TouchAction 操作. 先是用uiautomatorviewer.bat查询APP元素坐标: 手工计算九宫格每个 ...

  2. Appium九宫格滑动解锁

    1.适配各种机型,首先获取整个解锁元素的坐标 2.代码实现 WebElement lockPattern = driver.findElement(By.id("com.android.se ...

  3. APP自动化 -- 滑动解锁、滑动验证

    一.解锁 1.代码 2.效果 1)执行效果 2)点位效果

  4. uiautomator2 实现App九宫格解锁

    App九宫格解锁 之前在testerhome社区看见codeskyblue大佬写过一种方法,但是这种办法存在一个弊端,那就是多个点的坐标是写死的,也就是说要是换了部手机,九宫格解锁就行不通了,于是就想 ...

  5. Swift: 打造滑动解锁文字动画

    原文:Swift: 打造滑动解锁文字动画 最近木事,找出来玩了玩facebook的paper.到处都是那个"slide to unlock your phone"的效果啊.忽闪忽闪 ...

  6. hiho_1054_滑动解锁

    题目大意 智能手机九点屏幕滑动解锁,如果给出某些连接线段,求出经过所有给出线段的合法的滑动解锁手势的总数.题目链接: 滑动解锁 题目分析 首先,尝试求解没有给定线段情况下,所有合法的路径的总数.可以使 ...

  7. hihocoder#1054 : 滑动解锁(深度优先搜索)

    描述 滑动解锁是智能手机一项常用的功能.你需要在3x3的点阵上,从任意一个点开始,反复移动到一个尚未经过的"相邻"的点.这些划过的点所组成的有向折线,如果与预设的折线在图案.方向上 ...

  8. Selenium模拟JQuery滑动解锁

    滑动解锁一直做UI自动化的难点之一,我补一篇滑动解锁的例子,希望能给初做Web UI自动化测试的同学一些思路. 首先先看个例子. https://www.helloweba.com/demo/2017 ...

  9. hihocoder 1054 滑动解锁 dfs

    详细分析见滑动解锁分析 AC代码 #include <cstdio> #include <cmath> #include <cctype> #include < ...

随机推荐

  1. Access restriction: The method 'CharacterEncoder.encode(byte[])' is not API...

    问题描述:Access restriction: The method 'CharacterEncoder.encode(byte[])' is not API... 解决方法:这种错误是eclips ...

  2. vueSSR渲染原理

    优点:利于搜索引擎,解决白屏问题,因为正常情况下在index.html文件中只有一个简单的标签,没有内容,不利于爬虫搜索 场景:交互少,数据多,例如新闻,博客,论坛类等 原理:相当于服务端前面加了一层 ...

  3. 如何稳定地使用 Google 搜索https://encrypted.google.com/

    方法很简单.用记事本打开 hosts 文件(Windows Vista 和 Windows 7 用户请先使用管理员权限打开记事本,然后将 hosts 文件拖进记事本中),在最下面添加如下内容: 203 ...

  4. paramiko使用exec_command执行rm -rf删除目录的坑

    paramiko删除目录后的上传操作请参考步骤1.2.3的说明 try: ssh = SSHClient(ip,user) sftpClient = ssh.getSftpClient() outpu ...

  5. C/C++中static关键字作用总结 && 指针与引用的比较

    static作用: 常规答案: 1. 全局变量的隐藏:2. 函数体内记忆功能:3.类所有实例共享,static函数不接受this指针,只能访问static成员变量. 拓展:1.全局变量的隐藏,因为在其 ...

  6. SpringBoot学习之快速入门创建

    maven构建项目 1.访问http://start.spring.io/,进入快速创建工程的主页 可参考下图所示: 2.选择构建工具Maven Project.Spring Boot版本1.3.6以 ...

  7. PHP生成excel(2)

    现在数据库有一组数据,就是按照年级的分类的学生分数,如何按照年级分类导出到excel表中 1.数据库配置文件config.php <?php $config = array( 'host'=&g ...

  8. Sublime Text2-Control Package---ShinePans

    1.打开sublime Text2 2.菜单条中的preference>>BrowsePackages 3.退到上一级打开Installed Packages 4.拷贝文件到此目录 (Pa ...

  9. Mac OS用docker Desktop安装单节点kubernetes

    方案: 安装方式:阿里云minikube,k8s官方minikube,kubeadm, docker Desktop中自带第k8s 安装环境:在linux虚拟机中安装k8s,在macos中安装k8s, ...

  10. 使用NetBeans生成jar包,并在jar包中添加资源

    在NetBeans中,执行Clean and Build便可得到jar文件 若要在jar中添加资源,先用压缩软件打开jar,然后将资源拖进当前归档文件即可 使用Class.getResource(St ...