Appium Appium + ios + 手势密码设置 已解决

SongBoya · 2014年12月23日 · 最后由 刘发财 回复于 2018年01月13日 · 1680 次阅读

Appium + iOS 小白,遇到了设置手势密码,实在不知道怎么办,请大神帮忙指导。有没有人成功过呢?
如图:

使用过的方法: Swipe

JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Double> swipeObject = new HashMap<String, Double>();
swipeObject.put("startX", 32.5);
swipeObject.put("startY", 118.5);
swipeObject.put("endX", 222.5);
swipeObject.put("endY", 118.5);
swipeObject.put("duration", 1.0);
js.executeScript("mobile: swipe", swipeObject);

Swipe 方法可能在 ios6.0 以后版本就不支持了。(未求证)

共收到 10 条回复 时间 点赞

你可以尝试下将 MultiTouchAction 中模仿 appium 自带的 swipe 用 TouchAction 中的方法组合试一下

#1 楼 @panzhigang 其实不一定要点四个点。。。只要能按一个点就行了。。。

#1 楼 @panzhigang 非常感谢,这个问题解决了

问题已解决,以后如果有人用,可以参考一下。

public void gesturePwd() {
    // 第一个点和第二个点  
    WebElement el1 = driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[1]"));
    WebElement el2 = driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[2]"));

    TouchAction action = new TouchAction(driver);
    action.longPress(el1).waitAction(1000).moveTo(el2).release().perform(); 
    }

不需要通过 ID 或者是 Name 来查询码?

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'

#4 楼 @april46 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'

yifenzhonghuxi 回复

Gesture = TouchAction(self.driver).press(el1).move_to(el2).move_to(el3).move_to(el4).release()
这里这样写:TouchAction(self.driver)

4 个点的要怎么解决啊?

需要 登录 後方可回應,如果你還沒有帳號按這裡 注册