新手区 appium ios 平台手势密码滑动的 python 代码如何写

lydia · 2015年03月05日 · 最后由 yifenzhonghuxi 回复于 2016年05月20日 · 1471 次阅读

appium ios 平台手势密码滑动的 python 代码如何写,谢谢!

共收到 10 条回复 时间 点赞

大概猜了一下
from appium.webdriver.common.touch_action import TouchAction
wd = TouchAction()
wd.press(x=110, y=200).move_to(x=110, y=200).move_to(x=110, y=200).release()
试试

这是 java 的代码,调用的是 TouchAction。就是不知道 python 是那个接口
TouchAction(driver).press(startX, stratY)
          .moveTo(startX, stratY + height)
          .moveTo(startX, stratY + height + height)
          .moveTo(startX + width, stratY + height + height).release()

#2 楼 @dingx010602
我试试看

ta = TouchAction()
ta.press(x=190, y=180).move_to(x=315, y=180).move_to(x=315, y=435).release()
这段代码执行后,感觉返回成功了,但是没有效果,结果并没有解锁。
如下是 appium 输出的 log:
: TalkingData: event 手势密码

info: [debug] Socket data received (25 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":""}

#5 楼 @lydia 你还得最后加上.perform()

def test_gestureUnlock(self):
#time.sleep(5)
el1 = self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[10]")
print el1
time.sleep(2)
el2 = self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[13]")
print el2
time.sleep(2)
el3 = self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[16]")
print el3
time.sleep(2)
el4 = self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[17]")
print el4
time.sleep(2)
Gesture = TouchAction().press(el1).move_to(el2).move_to(el3).move_to(el4).release()
print Gesture
time.sleep(2)
Gesture.perform()

请问 手势密码这一段有什么问题啊 一直提示如下错误:

File "/Library/Python/2.7/site-packages/appium/webdriver/common/touch_action.py", line 94, in perform
self._driver.execute(Command.TOUCH_ACTION, params)
AttributeError: 'NoneType' object has no attribute 'execute'
#6 楼 @weamylady

#8 楼 @yifenzhonghuxi TouchAction 你要传一个 driver 参数进去

#9 楼 @weamylady 已经解决,多谢

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册