Pinch代码:
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
日志似乎很好!!!!!!!