@Override public WebElement apply(final WebElement element) { return (WebElement) newProxyInstance( getClass().getClassLoader(), new Class[]{WebElement.class, WrapsElement.class, Locatable.class, HasIdentity.class}, invocationHandlerFor(element) ); }
@Override public String getId() { if ( webElement instanceof HasIdentity ) return ( (HasIdentity) webElement ).getId(); else return null; }
/** * This method forms a {@link java.util.Map} of parameters for the element * value replacement. It is used against input elements * * @param hasIdentityObject an instance which contains an element ID * @param value a new value * @return a key-value pair. The key is the command name. The value is a * {@link java.util.Map} command arguments. */ public static Map.Entry<String, Map<String, ?>> replaceElementValueCommand( HasIdentity hasIdentityObject, String value) { String[] parameters = new String[] {"id", "value"}; Object[] values = new Object[] {hasIdentityObject.getId(), value}; return new AbstractMap.SimpleEntry<String, Map<String, ?>>(REPLACE_VALUE, prepareArguments(parameters, values)); }
@Override public String toString() { if (seleniumElement == null) { return String.format("%s\n|- StaticElement <SeleniumElement: null><Locator: %s>", getParent(), locator); } return String.format("%s\n|- StaticElement <SeleniumElementId: %s><Locator: %s>", getParent(), ((HasIdentity) seleniumElement).getId(), locator); }
@Override public String toString() { if (seleniumElement == null) { return String.format("%s\n|- DynamicElement <SeleniumElement: null><Locator: %s><FoundBy: %s>", getParent(), locator, foundBy); } return String.format("%s\n|- DynamicElement <SeleniumElementId: %s><Locator: %s><FoundBy: %s>", getParent(), ((HasIdentity) seleniumElement).getId(), locator, foundBy); }
public ActionParameter(String actionName, HasIdentity el) { this.actionName = actionName; optionsBuilder = ImmutableMap.builder(); addParameter("element", el.getId()); }
/** * Press on an element, offset from upper left corner by a number of pixels. * * @param el element to press on. * @param x x offset. * @param y y offset. * @return this TouchAction, for chaining. */ public TouchAction press(WebElement el, int x, int y) { ActionParameter action = new ActionParameter("press", (HasIdentity) el); action.addParameter("x", x); action.addParameter("y", y); parameterBuilder.add(action); return this; }
/** * Move current touch to an element, offset from upper left corner. * * @param el element to move current touch to. * @param x x offset. * @param y y offset. * @return this TouchAction, for chaining. */ public TouchAction moveTo(WebElement el, int x, int y) { ActionParameter action = new ActionParameter("moveTo", (HasIdentity) el); action.addParameter("x", x); action.addParameter("y", y); parameterBuilder.add(action); return this; }
/** * Tap an element, offset from upper left corner. * * @param el element to tap. * @param x x offset. * @param y y offset. * @return this TouchAction, for chaining. */ public TouchAction tap(WebElement el, int x, int y) { ActionParameter action = new ActionParameter("tap", (HasIdentity) el); action.addParameter("x", x); action.addParameter("y", y); parameterBuilder.add(action); return this; }
/** * Press and hold the at the center of an element until the contextmenu event has fired. * * @param el element to long-press. * @param duration of the long-press, in milliseconds. * @return this TouchAction, for chaining. */ public TouchAction longPress(WebElement el, int duration) { ActionParameter action = new ActionParameter("longPress", (HasIdentity) el); action.addParameter("duration", duration); parameterBuilder.add(action); return this; }
/** * Press and hold the at an elements upper-left corner, offset by the given amount, * until the contextmenu event has fired. * * @param el element to long-press. * @param x x offset. * @param y y offset. * @return this TouchAction, for chaining. */ public TouchAction longPress(WebElement el, int x, int y) { ActionParameter action = new ActionParameter("longPress", (HasIdentity) el); action.addParameter("x", x); action.addParameter("y", y); parameterBuilder.add(action); return this; }
/** * Press and hold the at an elements upper-left corner, offset by the * given amount, until the contextmenu event has fired. * * @param el element to long-press. * @param x x offset. * @param y y offset. * @param duration of the long-press, in milliseconds. * @return this TouchAction, for chaining. */ public TouchAction longPress(WebElement el, int x, int y, int duration) { ActionParameter action = new ActionParameter("longPress", (HasIdentity) el); action.addParameter("x", x); action.addParameter("y", y); action.addParameter("duration", duration); parameterBuilder.add(action); return this; }
/** * Press on the center of an element. * * @param el element to press on. * @return this TouchAction, for chaining. */ public TouchAction press(WebElement el) { ActionParameter action = new ActionParameter("press", (HasIdentity) el); parameterBuilder.add(action); return this; }
/** * Move current touch to center of an element. * * @param el element to move to. * @return this TouchAction, for chaining. */ public TouchAction moveTo(WebElement el) { ActionParameter action = new ActionParameter("moveTo", (HasIdentity) el); parameterBuilder.add(action); return this; }
/** * Tap the center of an element. * * @param el element to tap. * @return this TouchAction, for chaining. */ public TouchAction tap(WebElement el) { ActionParameter action = new ActionParameter("tap", (HasIdentity) el); parameterBuilder.add(action); return this; }
/** * Press and hold the at the center of an element until the contextmenu event has fired. * * @param el element to long-press. * @return this TouchAction, for chaining. */ public TouchAction longPress(WebElement el) { ActionParameter action = new ActionParameter("longPress", (HasIdentity) el); parameterBuilder.add(action); return this; }