org.openqa.selenium.devtools.v130.input.Input Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of selenium-devtools-v130 Show documentation
Show all versions of selenium-devtools-v130 Show documentation
Selenium automates browsers. That's it! What you do with that power is entirely up to you.
The newest version!
package org.openqa.selenium.devtools.v130.input;
import org.openqa.selenium.Beta;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.ConverterFunctions;
import java.util.Map;
import java.util.LinkedHashMap;
import org.openqa.selenium.json.JsonInput;
public class Input {
public enum DispatchDragEventType {
DRAGENTER("dragEnter"), DRAGOVER("dragOver"), DROP("drop"), DRAGCANCEL("dragCancel");
private String value;
DispatchDragEventType(String value) {
this.value = value;
}
public static DispatchDragEventType fromString(String s) {
return java.util.Arrays.stream(DispatchDragEventType.values()).filter(rs -> rs.value.equalsIgnoreCase(s)).findFirst().orElseThrow(() -> new org.openqa.selenium.devtools.DevToolsException("Given value " + s + " is not found within DispatchDragEventType "));
}
public String toString() {
return value;
}
public String toJson() {
return value;
}
private static DispatchDragEventType fromJson(JsonInput input) {
return fromString(input.nextString());
}
}
/**
* Dispatches a drag event into the page.
*/
@Beta()
public static Command dispatchDragEvent(DispatchDragEventType type, java.lang.Number x, java.lang.Number y, org.openqa.selenium.devtools.v130.input.model.DragData data, java.util.Optional modifiers) {
java.util.Objects.requireNonNull(type, "type is required");
java.util.Objects.requireNonNull(x, "x is required");
java.util.Objects.requireNonNull(y, "y is required");
java.util.Objects.requireNonNull(data, "data is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("type", type);
params.put("x", x);
params.put("y", y);
params.put("data", data);
modifiers.ifPresent(p -> params.put("modifiers", p));
return new Command<>("Input.dispatchDragEvent", Map.copyOf(params));
}
public enum DispatchKeyEventType {
KEYDOWN("keyDown"), KEYUP("keyUp"), RAWKEYDOWN("rawKeyDown"), CHAR("char");
private String value;
DispatchKeyEventType(String value) {
this.value = value;
}
public static DispatchKeyEventType fromString(String s) {
return java.util.Arrays.stream(DispatchKeyEventType.values()).filter(rs -> rs.value.equalsIgnoreCase(s)).findFirst().orElseThrow(() -> new org.openqa.selenium.devtools.DevToolsException("Given value " + s + " is not found within DispatchKeyEventType "));
}
public String toString() {
return value;
}
public String toJson() {
return value;
}
private static DispatchKeyEventType fromJson(JsonInput input) {
return fromString(input.nextString());
}
}
/**
* Dispatches a key event to the page.
*/
public static Command dispatchKeyEvent(DispatchKeyEventType type, java.util.Optional modifiers, java.util.Optional timestamp, java.util.Optional text, java.util.Optional unmodifiedText, java.util.Optional keyIdentifier, java.util.Optional code, java.util.Optional key, java.util.Optional windowsVirtualKeyCode, java.util.Optional nativeVirtualKeyCode, java.util.Optional autoRepeat, java.util.Optional isKeypad, java.util.Optional isSystemKey, java.util.Optional location, java.util.Optional> commands) {
java.util.Objects.requireNonNull(type, "type is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("type", type);
modifiers.ifPresent(p -> params.put("modifiers", p));
timestamp.ifPresent(p -> params.put("timestamp", p));
text.ifPresent(p -> params.put("text", p));
unmodifiedText.ifPresent(p -> params.put("unmodifiedText", p));
keyIdentifier.ifPresent(p -> params.put("keyIdentifier", p));
code.ifPresent(p -> params.put("code", p));
key.ifPresent(p -> params.put("key", p));
windowsVirtualKeyCode.ifPresent(p -> params.put("windowsVirtualKeyCode", p));
nativeVirtualKeyCode.ifPresent(p -> params.put("nativeVirtualKeyCode", p));
autoRepeat.ifPresent(p -> params.put("autoRepeat", p));
isKeypad.ifPresent(p -> params.put("isKeypad", p));
isSystemKey.ifPresent(p -> params.put("isSystemKey", p));
location.ifPresent(p -> params.put("location", p));
commands.ifPresent(p -> params.put("commands", p));
return new Command<>("Input.dispatchKeyEvent", Map.copyOf(params));
}
/**
* This method emulates inserting text that doesn't come from a key press,
* for example an emoji keyboard or an IME.
*/
@Beta()
public static Command insertText(java.lang.String text) {
java.util.Objects.requireNonNull(text, "text is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("text", text);
return new Command<>("Input.insertText", Map.copyOf(params));
}
/**
* This method sets the current candidate text for IME.
* Use imeCommitComposition to commit the final text.
* Use imeSetComposition with empty string as text to cancel composition.
*/
@Beta()
public static Command imeSetComposition(java.lang.String text, java.lang.Integer selectionStart, java.lang.Integer selectionEnd, java.util.Optional replacementStart, java.util.Optional replacementEnd) {
java.util.Objects.requireNonNull(text, "text is required");
java.util.Objects.requireNonNull(selectionStart, "selectionStart is required");
java.util.Objects.requireNonNull(selectionEnd, "selectionEnd is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("text", text);
params.put("selectionStart", selectionStart);
params.put("selectionEnd", selectionEnd);
replacementStart.ifPresent(p -> params.put("replacementStart", p));
replacementEnd.ifPresent(p -> params.put("replacementEnd", p));
return new Command<>("Input.imeSetComposition", Map.copyOf(params));
}
public enum DispatchMouseEventType {
MOUSEPRESSED("mousePressed"), MOUSERELEASED("mouseReleased"), MOUSEMOVED("mouseMoved"), MOUSEWHEEL("mouseWheel");
private String value;
DispatchMouseEventType(String value) {
this.value = value;
}
public static DispatchMouseEventType fromString(String s) {
return java.util.Arrays.stream(DispatchMouseEventType.values()).filter(rs -> rs.value.equalsIgnoreCase(s)).findFirst().orElseThrow(() -> new org.openqa.selenium.devtools.DevToolsException("Given value " + s + " is not found within DispatchMouseEventType "));
}
public String toString() {
return value;
}
public String toJson() {
return value;
}
private static DispatchMouseEventType fromJson(JsonInput input) {
return fromString(input.nextString());
}
}
public enum DispatchMouseEventPointerType {
MOUSE("mouse"), PEN("pen");
private String value;
DispatchMouseEventPointerType(String value) {
this.value = value;
}
public static DispatchMouseEventPointerType fromString(String s) {
return java.util.Arrays.stream(DispatchMouseEventPointerType.values()).filter(rs -> rs.value.equalsIgnoreCase(s)).findFirst().orElseThrow(() -> new org.openqa.selenium.devtools.DevToolsException("Given value " + s + " is not found within DispatchMouseEventPointerType "));
}
public String toString() {
return value;
}
public String toJson() {
return value;
}
private static DispatchMouseEventPointerType fromJson(JsonInput input) {
return fromString(input.nextString());
}
}
/**
* Dispatches a mouse event to the page.
*/
public static Command dispatchMouseEvent(DispatchMouseEventType type, java.lang.Number x, java.lang.Number y, java.util.Optional modifiers, java.util.Optional timestamp, java.util.Optional button, java.util.Optional buttons, java.util.Optional clickCount, java.util.Optional force, java.util.Optional tangentialPressure, java.util.Optional tiltX, java.util.Optional tiltY, java.util.Optional twist, java.util.Optional deltaX, java.util.Optional deltaY, java.util.Optional pointerType) {
java.util.Objects.requireNonNull(type, "type is required");
java.util.Objects.requireNonNull(x, "x is required");
java.util.Objects.requireNonNull(y, "y is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("type", type);
params.put("x", x);
params.put("y", y);
modifiers.ifPresent(p -> params.put("modifiers", p));
timestamp.ifPresent(p -> params.put("timestamp", p));
button.ifPresent(p -> params.put("button", p));
buttons.ifPresent(p -> params.put("buttons", p));
clickCount.ifPresent(p -> params.put("clickCount", p));
force.ifPresent(p -> params.put("force", p));
tangentialPressure.ifPresent(p -> params.put("tangentialPressure", p));
tiltX.ifPresent(p -> params.put("tiltX", p));
tiltY.ifPresent(p -> params.put("tiltY", p));
twist.ifPresent(p -> params.put("twist", p));
deltaX.ifPresent(p -> params.put("deltaX", p));
deltaY.ifPresent(p -> params.put("deltaY", p));
pointerType.ifPresent(p -> params.put("pointerType", p));
return new Command<>("Input.dispatchMouseEvent", Map.copyOf(params));
}
public enum DispatchTouchEventType {
TOUCHSTART("touchStart"), TOUCHEND("touchEnd"), TOUCHMOVE("touchMove"), TOUCHCANCEL("touchCancel");
private String value;
DispatchTouchEventType(String value) {
this.value = value;
}
public static DispatchTouchEventType fromString(String s) {
return java.util.Arrays.stream(DispatchTouchEventType.values()).filter(rs -> rs.value.equalsIgnoreCase(s)).findFirst().orElseThrow(() -> new org.openqa.selenium.devtools.DevToolsException("Given value " + s + " is not found within DispatchTouchEventType "));
}
public String toString() {
return value;
}
public String toJson() {
return value;
}
private static DispatchTouchEventType fromJson(JsonInput input) {
return fromString(input.nextString());
}
}
/**
* Dispatches a touch event to the page.
*/
public static Command dispatchTouchEvent(DispatchTouchEventType type, java.util.List touchPoints, java.util.Optional modifiers, java.util.Optional timestamp) {
java.util.Objects.requireNonNull(type, "type is required");
java.util.Objects.requireNonNull(touchPoints, "touchPoints is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("type", type);
params.put("touchPoints", touchPoints);
modifiers.ifPresent(p -> params.put("modifiers", p));
timestamp.ifPresent(p -> params.put("timestamp", p));
return new Command<>("Input.dispatchTouchEvent", Map.copyOf(params));
}
/**
* Cancels any active dragging in the page.
*/
public static Command cancelDragging() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Input.cancelDragging", Map.copyOf(params));
}
public enum EmulateTouchFromMouseEventType {
MOUSEPRESSED("mousePressed"), MOUSERELEASED("mouseReleased"), MOUSEMOVED("mouseMoved"), MOUSEWHEEL("mouseWheel");
private String value;
EmulateTouchFromMouseEventType(String value) {
this.value = value;
}
public static EmulateTouchFromMouseEventType fromString(String s) {
return java.util.Arrays.stream(EmulateTouchFromMouseEventType.values()).filter(rs -> rs.value.equalsIgnoreCase(s)).findFirst().orElseThrow(() -> new org.openqa.selenium.devtools.DevToolsException("Given value " + s + " is not found within EmulateTouchFromMouseEventType "));
}
public String toString() {
return value;
}
public String toJson() {
return value;
}
private static EmulateTouchFromMouseEventType fromJson(JsonInput input) {
return fromString(input.nextString());
}
}
/**
* Emulates touch event from the mouse event parameters.
*/
@Beta()
public static Command emulateTouchFromMouseEvent(EmulateTouchFromMouseEventType type, java.lang.Integer x, java.lang.Integer y, org.openqa.selenium.devtools.v130.input.model.MouseButton button, java.util.Optional timestamp, java.util.Optional deltaX, java.util.Optional deltaY, java.util.Optional modifiers, java.util.Optional clickCount) {
java.util.Objects.requireNonNull(type, "type is required");
java.util.Objects.requireNonNull(x, "x is required");
java.util.Objects.requireNonNull(y, "y is required");
java.util.Objects.requireNonNull(button, "button is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("type", type);
params.put("x", x);
params.put("y", y);
params.put("button", button);
timestamp.ifPresent(p -> params.put("timestamp", p));
deltaX.ifPresent(p -> params.put("deltaX", p));
deltaY.ifPresent(p -> params.put("deltaY", p));
modifiers.ifPresent(p -> params.put("modifiers", p));
clickCount.ifPresent(p -> params.put("clickCount", p));
return new Command<>("Input.emulateTouchFromMouseEvent", Map.copyOf(params));
}
/**
* Ignores input events (useful while auditing page).
*/
public static Command setIgnoreInputEvents(java.lang.Boolean ignore) {
java.util.Objects.requireNonNull(ignore, "ignore is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("ignore", ignore);
return new Command<>("Input.setIgnoreInputEvents", Map.copyOf(params));
}
/**
* Prevents default drag and drop behavior and instead emits `Input.dragIntercepted` events.
* Drag and drop behavior can be directly controlled via `Input.dispatchDragEvent`.
*/
@Beta()
public static Command setInterceptDrags(java.lang.Boolean enabled) {
java.util.Objects.requireNonNull(enabled, "enabled is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("enabled", enabled);
return new Command<>("Input.setInterceptDrags", Map.copyOf(params));
}
/**
* Synthesizes a pinch gesture over a time period by issuing appropriate touch events.
*/
@Beta()
public static Command synthesizePinchGesture(java.lang.Number x, java.lang.Number y, java.lang.Number scaleFactor, java.util.Optional relativeSpeed, java.util.Optional gestureSourceType) {
java.util.Objects.requireNonNull(x, "x is required");
java.util.Objects.requireNonNull(y, "y is required");
java.util.Objects.requireNonNull(scaleFactor, "scaleFactor is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("x", x);
params.put("y", y);
params.put("scaleFactor", scaleFactor);
relativeSpeed.ifPresent(p -> params.put("relativeSpeed", p));
gestureSourceType.ifPresent(p -> params.put("gestureSourceType", p));
return new Command<>("Input.synthesizePinchGesture", Map.copyOf(params));
}
/**
* Synthesizes a scroll gesture over a time period by issuing appropriate touch events.
*/
@Beta()
public static Command synthesizeScrollGesture(java.lang.Number x, java.lang.Number y, java.util.Optional xDistance, java.util.Optional yDistance, java.util.Optional xOverscroll, java.util.Optional yOverscroll, java.util.Optional preventFling, java.util.Optional speed, java.util.Optional gestureSourceType, java.util.Optional repeatCount, java.util.Optional repeatDelayMs, java.util.Optional interactionMarkerName) {
java.util.Objects.requireNonNull(x, "x is required");
java.util.Objects.requireNonNull(y, "y is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("x", x);
params.put("y", y);
xDistance.ifPresent(p -> params.put("xDistance", p));
yDistance.ifPresent(p -> params.put("yDistance", p));
xOverscroll.ifPresent(p -> params.put("xOverscroll", p));
yOverscroll.ifPresent(p -> params.put("yOverscroll", p));
preventFling.ifPresent(p -> params.put("preventFling", p));
speed.ifPresent(p -> params.put("speed", p));
gestureSourceType.ifPresent(p -> params.put("gestureSourceType", p));
repeatCount.ifPresent(p -> params.put("repeatCount", p));
repeatDelayMs.ifPresent(p -> params.put("repeatDelayMs", p));
interactionMarkerName.ifPresent(p -> params.put("interactionMarkerName", p));
return new Command<>("Input.synthesizeScrollGesture", Map.copyOf(params));
}
/**
* Synthesizes a tap gesture over a time period by issuing appropriate touch events.
*/
@Beta()
public static Command synthesizeTapGesture(java.lang.Number x, java.lang.Number y, java.util.Optional duration, java.util.Optional tapCount, java.util.Optional gestureSourceType) {
java.util.Objects.requireNonNull(x, "x is required");
java.util.Objects.requireNonNull(y, "y is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("x", x);
params.put("y", y);
duration.ifPresent(p -> params.put("duration", p));
tapCount.ifPresent(p -> params.put("tapCount", p));
gestureSourceType.ifPresent(p -> params.put("gestureSourceType", p));
return new Command<>("Input.synthesizeTapGesture", Map.copyOf(params));
}
public static Event dragIntercepted() {
return new Event<>("Input.dragIntercepted", ConverterFunctions.map("data", org.openqa.selenium.devtools.v130.input.model.DragData.class));
}
}