/** * 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); }
/** * Gets the given bounds equivalent relative to the bounds upper left corner; * * @param bounds * - {@link Bounds} for which to get the relative bounds to the bounds upper left corner * @return the bounds equivalent relative to the bounds upper left corner */ public Bounds getRelativeBounds(Bounds bounds) { Point boundsUpperLeftCorner = bounds.getUpperLeftCorner(); int boundsWidth = bounds.getWidth(); int boundsHeight = bounds.getHeight(); Point relativeUpperLeftCorner = getRelativePoint(boundsUpperLeftCorner); Bounds relativeBounds = new Bounds(relativeUpperLeftCorner, boundsWidth, boundsHeight); return relativeBounds; }