Appium之解锁九宫格

 

解锁手机应用的九宫格密码

具体思路:

1、先通过Uiautomator2定位密码轨迹的坐标点;

2、使用TouchAction类的press(按压)和move_to(移动至)方法,模拟手势移动;

from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction

desired_caps = {
    'autoLaunch': 'True',
    'deviceName': 'Honor10.0',
    'platformVersion': '10.0',
    'platformName': 'Android',
    'noReset': 'True',
    'appPackage': 'com.fenbi.android.solar',
    'appActivity': 'com.fenbi.android.solar.activity.RouterActivity',
}

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
TouchAction(driver).press(x=203, y=695).wait(100).move_to(x=509, y=690).wait(100).move_to(x=813, y=681).wait(100).
    move_to(x=843, y=948).wait(100).move_to(x=509, y=948).wait(100).move_to(x=217, y=948).wait(100).
    move_to(x=205, y=1281).wait(100).move_to(x=509, y=1292).wait(100).move_to(x=843, y=1297).wait(100).release().perform()  # 注意release()和perform()的顺序
原文地址:https://www.cnblogs.com/Maruying/p/13647399.html