4

捏代码:

def contract(self, from_loc_up, from_loc_down):
    window_size = self.driver.get_window_size()
    xx = window_size["width"] / 2
    yy = window_size["height"] / 2
    yy_d = (from_loc_down - from_loc_up) / 2
    action1 = TouchAction(self.driver)
    action1.long_press(x=xx, y=yy - yy_d).move_to(x=0, y=100).wait(500).release()
    action2 = TouchAction(self.driver)
    action2.long_press(x=xx, y=yy + yy_d).move_to(x=0, y=-100).wait(500).release()
    m_action = MultiAction(self.driver)
    m_action.add(action2, action1)
    m_action.perform()

出于某种原因,这个应该捏的代码没有这样做,而是放大了一点。

而缩放的类似代码工作正常。

缩放代码:

def zoom(self, to_loc):
    window_size = self.driver.get_window_size()
    xx = window_size["width"] / 2
    yy = window_size["height"] / 2
    to = abs(to_loc - yy)
    action1 = TouchAction(self.driver)
    action1.long_press(x=xx, y=yy).move_to(x=0, y=-to).wait(100).release()
    action2 = TouchAction(self.driver)
    action2.long_press(x=xx, y=yy).move_to(x=0, y=to).wait(100).release()
    m_action = MultiAction(self.driver)
    m_action.add(action1, action2)
    m_action.perform()

知道为什么multiaction会失败,pinch但对zoom. 不过appium日志看起来不错!!!!!!!

4

0 回答 0