Example usage for org.openqa.selenium Point getY

List of usage examples for org.openqa.selenium Point getY

Introduction

In this page you can find the example usage for org.openqa.selenium Point getY.

Prototype

public int getY() 

Source Link

Usage

From source file:com.github.wasiqb.coteafs.appium.ios.IOSDeviceElementActions.java

License:Apache License

@Override
public void dragDrop(final MobileElement dropElement) {
    log.info(format("Performing drag on element [%s]...", this.name));
    final Point fromCenter = this.element.getCenter();
    final Point fromLocation = this.element.getLocation();
    final Point toCenter = dropElement.getCenter();

    final Map<String, Object> param = prepareParam();
    param.put("duration", this.setting.getDelayBeforeSwipe());
    param.put("fromX", fromCenter.getX() - fromLocation.getX());
    param.put("fromY", fromCenter.getY() - fromLocation.getY());
    param.put("toX", toCenter.getX() - fromLocation.getX());
    param.put("toY", toCenter.getY() - fromLocation.getY());
    this.device.executeCommand("mobile: dragFromToForDuration", param);
}

From source file:com.github.wasiqb.coteafs.appium.ios.IOSDeviceElementActions.java

License:Apache License

@Override
public void tap() {
    log.info(format("Tapping on element [%s]...", this.name));
    final Point center = this.element.getCenter();
    final Point location = this.element.getLocation();

    final Map<String, Object> param = prepareParam();
    param.put("x", center.getX() - location.getX());
    param.put("y", center.getY() - location.getY());
    this.device.executeCommand("mobile: tap", param);
}

From source file:com.github.wasiqb.coteafs.appium.utils.SwipeUtils.java

License:Apache License

/**
 * @author wasiq.bhamla// ww  w. j  a v  a  2s . c o  m
 * @since Feb 2, 2018 3:25:54 PM
 * @param setting
 * @param fromElement
 * @param toElement
 * @param actions
 * @return touch action
 */
public static <T extends TouchAction<T>> T dragTo(final PlaybackSetting setting,
        final MobileElement fromElement, final MobileElement toElement, final T actions) {
    final Point source = fromElement.getCenter();
    final Point target = toElement.getCenter();
    return actions.press(PointOption.point(source.getX(), source.getY()))
            .waitAction(WaitOptions.waitOptions(Duration.ofMillis(setting.getDelayBeforeSwipe())))
            .moveTo(PointOption.point(target.getX(), target.getY())).release()
            .waitAction(WaitOptions.waitOptions(Duration.ofMillis(setting.getDelayAfterSwipe())));
}

From source file:com.github.wasiqb.coteafs.appium.utils.SwipeUtils.java

License:Apache License

/**
 * @author wasiq.bhamla//from   w ww  .  ja va 2 s  .  c o m
 * @since Sep 18, 2018 8:03:55 PM
 * @param direction
 * @param startPosition
 * @param distancePercent
 * @param setting
 * @param screenSize
 * @param elementSize
 * @param elementLocation
 * @param actions
 * @return action
 */
public static <T extends TouchAction<T>> T swipeTo(final SwipeDirection direction,
        final SwipeStartPosition startPosition, final int distancePercent, final PlaybackSetting setting,
        final Dimension screenSize, final Dimension elementSize, final Point elementLocation, final T actions) {
    final double distance = distancePercent / 100.0;
    final Point source = getStartPoint(startPosition, screenSize, elementSize, elementLocation);
    int endX = source.getX() + (int) (source.getX() * direction.getX() * distance);
    int endY = source.getY() + (int) (source.getY() * direction.getY() * distance);
    if (elementSize != null) {
        endX = source.getX() + (int) (elementSize.getWidth() * direction.getX() * distance);
        endY = source.getY() + (int) (elementSize.getHeight() * direction.getY() * distance);
    }
    return actions.press(PointOption.point(source.getX(), source.getY()))
            .waitAction(WaitOptions.waitOptions(Duration.ofMillis(setting.getDelayBeforeSwipe())))
            .moveTo(PointOption.point(endX, endY)).release();
}

From source file:com.github.wasiqb.coteafs.appium.utils.SwipeUtils.java

License:Apache License

private static Point getStartPoint(final SwipeStartPosition start, final Dimension screenSize,
        final Dimension elementSize, final Point elementLocation) {
    int x = 0;/*from  w  w w . j  a v a  2  s .c  o m*/
    int y = 0;
    int width = screenSize.getWidth();
    int height = screenSize.getHeight();
    Point location = new Point(0, 0);

    if (elementSize != null) {
        width = elementSize.getWidth();
        height = elementSize.getHeight();
        location = elementLocation;
    }

    switch (start) {
    case BOTTOM:
        x = width / 2;
        y = elementSize != null && height + location.getY() < screenSize.getHeight() ? height : height - 5;
        break;
    case CENTER:
        x = width / 2;
        y = height / 2;
        break;
    case LEFT:
        x = elementSize != null && width + location.getX() > 0 ? 0 : 5;
        y = height / 2;
        break;
    case RIGHT:
        x = elementSize != null && width + location.getX() < screenSize.getWidth() ? width : width - 5;
        y = height / 2;
        break;
    case TOP:
    default:
        x = width / 2;
        y = 5;
        break;
    }
    return new Point(location.getX() + x, location.getY() + y);
}

From source file:com.google.android.testing.nativedriver.server.AndroidNativeTouch.java

License:Apache License

@Override
public synchronized void tap(@Nullable Coordinates where) {
    if (!isTouchStateReleased()) {
        throw new IllegalStateException("Attempt to tap when touch state is already down");
    }/*from w  ww  .jav a  2 s .  co m*/
    updateActiveCoordinates(where);
    Point point = currentActiveCoordinates.getLocationOnScreen();
    tap(point.getX(), point.getY());
}

From source file:com.google.android.testing.nativedriver.server.AndroidNativeTouch.java

License:Apache License

@Override
public synchronized void doubleTap(@Nullable Coordinates where) {
    if (!isTouchStateReleased()) {
        throw new IllegalStateException("Attempt to double tap when touch state is already down");
    }/*from   w ww  .j a v  a 2 s  .  com*/
    updateActiveCoordinates(where);
    Point point = currentActiveCoordinates.getLocationOnScreen();
    doubleTap(point.getX(), point.getY());
}

From source file:com.google.android.testing.nativedriver.server.AndroidNativeTouch.java

License:Apache License

@Override
public synchronized void touchDown(@Nullable Coordinates where) {
    if (!isTouchStateReleased()) {
        throw new IllegalStateException("Attempt to touch down when touch state is already down");
    }/*from   w w w. j ava 2 s.  c  om*/
    updateActiveCoordinates(where);
    Point point = currentActiveCoordinates.getLocationOnScreen();
    touchDown(point.getX(), point.getY());
}

From source file:com.google.android.testing.nativedriver.server.AndroidNativeTouch.java

License:Apache License

@Override
public synchronized void touchUp(@Nullable Coordinates where) {
    if (isTouchStateReleased()) {
        throw new IllegalStateException("Attempt to release touch when touch is already released");
    }//from   w w w  .java  2s .  c  o m
    updateActiveCoordinates(where);
    Point point = currentActiveCoordinates.getLocationOnScreen();
    touchUp(point.getX(), point.getY());
}

From source file:com.google.android.testing.nativedriver.server.AndroidNativeTouch.java

License:Apache License

@Override
public synchronized void touchMove(Coordinates where) {
    Preconditions.checkNotNull(where);/*from w w w. j  a  va2 s.co  m*/
    updateActiveCoordinates(where);
    if (!isTouchStateReleased()) {
        Point point = where.getLocationOnScreen();
        touchMove(point.getX(), point.getY());
    }
}