/** * Drags the element until his center point stands at (Point endPoint) on the screen. * * @param endPoint * - the point where we want to move the element * @return <code>true</code> if the dragging is successful, <code>false</code> if it fails */ public boolean drag(Point endPoint) { Point startPoint = propertiesContainer.getBounds().getCenter(); return (boolean) communicator.sendAction(RoutingAction.GESTURE_DRAG, startPoint, endPoint); }
/** * Simulates swiping this UiElement. * * @param swipeDirection * - a {@link SwipeDirection}, describing the direction of the swipe. * @return <code>true</code> if the swiping is successful, <code>false</code> if it fails * @throws StaleElementReferenceException * if the element has become stale before executing this method */ public boolean swipe(SwipeDirection swipeDirection) { Bounds elementBounds = propertiesContainer.getBounds(); Point centerPoint = elementBounds.getCenter(); return swipe(centerPoint, swipeDirection); }
/** * Drags the element to the center of another element. * * @param destinationElement * - destination element * @return <code>true</code> if the dragging is successful, <code>false</code> if it fails * @throws MultipleElementsFoundException * when selector's query finds multiple elements * @throws InvalidCssQueryException * when an invalid CSS query is used * @throws UiElementFetchingException * when trying to fetch UiElement but it does not exist on the screen */ public boolean drag(UiElement destinationElement) throws UiElementFetchingException, InvalidCssQueryException, MultipleElementsFoundException { Point startPoint = propertiesContainer.getBounds().getCenter(); Point endPoint = destinationElement.getProperties().getBounds().getCenter(); return (boolean) communicator.sendAction(RoutingAction.GESTURE_DRAG, startPoint, endPoint); }
/** * Simulates tapping in the center of this UI Element. * * @return <code>true</code> if the tapping is successful, <code>false</code> if it fails * @throws StaleElementReferenceException * if the element has become stale before executing this method */ public boolean tap() { Bounds elementBounds = propertiesContainer.getBounds(); Point centerPoint = elementBounds.getCenter(); Point tapPoint = elementBounds.getRelativePoint(centerPoint); return tap(tapPoint); }
/** * Simulates double-tapping in the center of this UiElement. * * @return <code>true</code> if the double tapping is successful, <code>false</code> if it fails * @throws StaleElementReferenceException * if the element has become stale before executing this method * */ public boolean doubleTap() { Bounds elementBounds = propertiesContainer.getBounds(); Point centerPoint = elementBounds.getCenter(); Point tapPoint = elementBounds.getRelativePoint(centerPoint); return doubleTap(tapPoint); }
/** * Simulates long press on the current element with default timeout value. * * @return true, if operation is successful, and false otherwise * @throws StaleElementReferenceException * if the element has become stale before executing this method * @see Device#LONG_PRESS_DEFAULT_TIMEOUT */ public boolean longPress() { Bounds elementBounds = propertiesContainer.getBounds(); Point centerPoint = elementBounds.getCenter(); Point tapPoint = elementBounds.getRelativePoint(centerPoint); return longPress(tapPoint, Device.LONG_PRESS_DEFAULT_TIMEOUT); }
/** * Simulates long press on the current element with passed timeout value. * * @param timeout * - time in ms for which the element should be held * @return true, if operation is successful, and false otherwise * @throws StaleElementReferenceException * if the element has become stale before executing this method */ public boolean longPress(int timeout) { Bounds elementBounds = propertiesContainer.getBounds(); Point centerPoint = elementBounds.getCenter(); Point tapPoint = elementBounds.getRelativePoint(centerPoint); return longPress(tapPoint, timeout); }
/** * Drags the element to the center of an element with given selector. * * @param destinationSelector * - selector of the destination element * @return <code>true</code> if the dragging is successful, <code>false</code> if it fails * @throws MultipleElementsFoundException * when selector's query finds multiple elements * @throws InvalidCssQueryException * when an invalid CSS query is used * @throws UiElementFetchingException * when trying to fetch UiElement but it does not exist on the screen * @throws XPathExpressionException * when there is error in the Xpath expression */ public boolean drag(UiElementSelector destinationSelector) throws XPathExpressionException, UiElementFetchingException, InvalidCssQueryException, MultipleElementsFoundException { UiElement destinationElement = elementUtils.getElement(destinationSelector, true); Point startPoint = propertiesContainer.getBounds().getCenter(); Point endPoint = destinationElement.getProperties().getBounds().getCenter(); return (boolean) communicator.sendAction(RoutingAction.GESTURE_DRAG, startPoint, endPoint); }
/** * Drags the element to the center of an element with given text * * @param destinationElementText * - the text of the destination element * @return <code>true</code> if the dragging is successful, <code>false</code> if it fails * @throws XPathExpressionException * when an invalid XPath expression * @throws UiElementFetchingException * when cannot fetch UiElement * @throws MultipleElementsFoundException * when multiple elements are found * @throws InvalidCssQueryException * when an invalid CSS query is used */ public boolean drag(String destinationElementText) throws XPathExpressionException, UiElementFetchingException, MultipleElementsFoundException, InvalidCssQueryException { UiElementSelector selector = new UiElementSelector(); selector.addSelectionAttribute(CssAttribute.TEXT, destinationElementText); UiElement destinationElement = elementUtils.getElement(selector, true); Point startPoint = propertiesContainer.getBounds().getCenter(); Point endPoint = destinationElement.propertiesContainer.getBounds().getCenter(); return (boolean) communicator.sendAction(RoutingAction.GESTURE_DRAG, startPoint, endPoint); }