public Actions addAction(Action a) { this.action.addAction(a); return this; }
/** * Generates a composite action containing all actions so far, ready to be performed (and * resets the internal builder state, so subsequent calls to {@link #build()} will contain fresh * sequences). * * @return the composite action */ public Action build() { Action toReturn = new BuiltAction(driver, new LinkedHashMap<>(sequences), action); action = new CompositeAction(); sequences.clear(); return toReturn; }
/** * Allows the execution of the gesture 'up' on the screen. It is typically the last of a sequence * of touch gestures. * * @param x The x coordinate relative to the viewport * @param y The y coordinate relative to the viewport * @return self */ public TouchActions up(int x, int y) { action.addAction(new UpAction(touchScreen, x, y)); return this; }
/** * Creates a scroll gesture that starts on a particular screen location. * * @param onElement the {@link WebElement} where the scroll starts. * @param xOffset The x offset to scroll * @param yOffset The y offset to scroll * @return self */ public TouchActions scroll(WebElement onElement, int xOffset, int yOffset) { action.addAction(new ScrollAction(touchScreen, (Locatable) onElement, xOffset, yOffset)); return this; }
/** * Allows the execution of single tap on the screen, analogous to click using a Mouse. * * @param onElement the {@link WebElement} on the screen. * @return self */ public TouchActions singleTap(WebElement onElement) { action.addAction(new SingleTapAction(touchScreen, (Locatable) onElement)); return this; }
/** * Allows the view to be scrolled by an x and y offset. * * @param xOffset The horizontal offset relative to the viewport * @param yOffset The vertical offset relative to the viewport * @return self */ public TouchActions scroll(int xOffset, int yOffset) { action.addAction(new ScrollAction(touchScreen, xOffset, yOffset)); return this; }
/** * Allows the execution of the gesture 'down' on the screen. It is typically the first of a * sequence of touch gestures. * * @param x The x coordinate relative to the viewport * @param y The y coordinate relative to the viewport * @return self */ public TouchActions down(int x, int y) { action.addAction(new DownAction(touchScreen, x, y)); return this; }
/** * Allows the execution of the gesture 'move' on the screen. * * @param x The x coordinate relative to the viewport * @param y The y coordinate relative to the viewport * @return self */ public TouchActions move(int x, int y) { action.addAction(new MoveAction(touchScreen, x, y)); return this; }
/** * Allows the execution of long press gestures. * * @param onElement The {@link WebElement} to long press * @return self */ public TouchActions longPress(WebElement onElement) { action.addAction(new LongPressAction(touchScreen, (Locatable) onElement)); return this; }
/** * Allows the execution of double tapon the screen, analogous to double click using a Mouse. * * @param onElement The {@link WebElement} to double tap * @return self */ public TouchActions doubleTap(WebElement onElement) { action.addAction(new DoubleTapAction(touchScreen, (Locatable) onElement)); return this; }
/** * Sends a flick gesture to the current view. * * @param xSpeed The horizontal speed in pixels/second * @param ySpeed The vertical speed in pixels/second * @return self */ public TouchActions flick(int xSpeed, int ySpeed) { action.addAction(new FlickAction(touchScreen, xSpeed, ySpeed)); return this; }
/** * Allows the execution of flick gestures starting in a location's element. * * @param onElement The {@link WebElement} to flick on * @param xOffset The x offset relative to the viewport * @param yOffset The y offset relative to the viewport * @param speed speed to flick, 0 = normal, 1 = fast, 2 = slow * @return self */ public TouchActions flick(WebElement onElement, int xOffset, int yOffset, int speed) { action.addAction(new FlickAction(touchScreen, (Locatable) onElement, xOffset, yOffset, speed)); return this; } }
public Actions waitAction(final long timeInMillis) { action.addAction(new WaitAction(timeInMillis)); return this; }
public CustomActions waitUntilElementVisible(String locator) { action.addAction(new WaitUntilElementVisibleAction(helper, locator)); return this; }
public CustomActions waitUntilElementFound(String locator) { action.addAction(new WaitUntilElementFoundAction(helper, locator)); return this; }
public CustomActions simulateDragAndDrop(String srcLocator, String destLocator) { action.addAction(new SimulateDragAndDropAction(helper, srcLocator, destLocator)); return this; }
@Override public Actions sendKeys(WebElement element, CharSequence... keysToSend) { action.addAction( new SendKeysAction(keyboard, mouse, (Locatable) element, modifyCharSequence(keysToSend))); return this; }
public Actions tick(Action action) { if (!(action instanceof IsInteraction)) { throw new IllegalStateException("Expected action to implement IsInteraction"); } for (Interaction interaction : ((IsInteraction) action).asInteractions(defaultMouse, defaultKeyboard)) { tick(interaction); } if (isBuildingActions()) { this.action.addAction(action); } return this; }
public Actions pause(Duration duration) { Objects.requireNonNull(duration, "Duration of pause not set"); if (isBuildingActions()) { action.addAction(new PauseAction(duration.toMillis())); } return tick(new Pause(defaultMouse, duration)); }
/** * Performs a context-click at the current mouse location. * @return A self reference. */ public Actions contextClick() { if (isBuildingActions()) { action.addAction(new ContextClickAction(jsonMouse, null)); } return clickInTicks(RIGHT); }