def air_drag_and_drop(self, s, t): """ Perform the drag and drop action on the current page by image identification. Args: v: target to drag and drop, either a Template instance or absolute coordinates (x, y) Returns: Finial position to be drag and drop. """ if not isinstance(self.driver, (WebChrome, WebFirefox, WebRemote)): raise AssertionError( 'Use this function, the driver is must be WebChrome, WebFirefox or WebRemote' ) if isinstance(s, Template): _pos_s = loop_find(s, timeout=ST.FIND_TIMEOUT, driver=self.driver) else: _pos_s = s x_s, y_s = _pos_s if isinstance(t, Template): _pos_t = loop_find(t, timeout=ST.FIND_TIMEOUT, driver=self.driver) else: _pos_t = t x_t, y_t = _pos_t # pos = self.driver._get_left_up_offset() # pos = (pos[0] + x, pos[1] + y) self.driver.action_chains.move_by_offset( x_s, y_s).click_and_hold().move_by_offset(x_t, y_t).release().perform() time.sleep(1) return _pos_s, _pos_t
def zuobiao(self, v): """ Perform the touch action on the current page by image identification. Args: v: target to touch, either a Template instance or absolute coordinates (x, y) Returns: Finial position to be clicked. """ if isinstance(v, Template): _pos = loop_find(v, timeout=ST.FIND_TIMEOUT, driver=self) else: _pos = v x, y = _pos pos = self._get_left_up_offset() pos = (pos[0] + x, pos[1] + y) return pos
def assert_template(self, v, msg=""): """ Assert target exists on the current page. Args: v: target to touch, either a Template instance Raise: AssertionError - if target not found. Returns: Position of the template. """ if isinstance(v, Template): try: pos = loop_find(v, timeout=ST.FIND_TIMEOUT, driver=self) except TargetNotFoundError: raise AssertionError("Target template not found on screen.") else: return pos else: raise IsNotTemplateError("args is not a template")
def airtest_touch(self, v): """ Perform the touch action on the current page by image identification. Args: v: target to touch, either a Template instance or absolute coordinates (x, y) Returns: Finial position to be clicked. """ if isinstance(v, Template): _pos = loop_find(v, timeout=ST.FIND_TIMEOUT, driver=self) else: _pos = v x, y = _pos # self.action_chains.move_to_element_with_offset(root_element, x, y) # self.action_chains.click() pos = self._get_left_up_offset() pos = (pos[0] + x, pos[1] + y) self._move_to_pos(pos) self._click_current_pos() time.sleep(1) return _pos
def air_mouse_over(self, v): """ Perform the mouse over action on the current page by image identification. Args: v: target to mouse over, either a Template instance or absolute coordinates (x, y) Returns: Finial position to be mouse over. """ if not isinstance(self.driver, (WebChrome, WebFirefox, WebRemote)): raise AssertionError( 'Use this function, the driver is must be WebChrome, WebFirefox or WebRemote' ) if isinstance(v, Template): _pos = loop_find(v, timeout=ST.FIND_TIMEOUT, driver=self.driver) else: _pos = v x, y = _pos # pos = self.driver._get_left_up_offset() # pos = (pos[0] + x, pos[1] + y) self.driver.action_chains.move_by_offset(x, y).perform() time.sleep(1) return _pos