Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions java/src/org/openqa/selenium/interactions/Actions.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import java.util.Objects;
import java.util.Set;
import java.util.function.IntConsumer;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.PointerInput.Origin;
Expand All @@ -44,16 +46,17 @@
*
* <p>Call {@link #perform()} at the end of the method chain to actually perform the actions.
*/
@NullMarked
public class Actions {

private final WebDriver driver;

// W3C
private final Map<InputSource, Sequence> sequences = new HashMap<>();

private PointerInput activePointer;
private KeyInput activeKeyboard;
private WheelInput activeWheel;
private @Nullable PointerInput activePointer;
private @Nullable KeyInput activeKeyboard;
private @Nullable WheelInput activeWheel;
private Duration actionDuration;

public Actions(WebDriver driver) {
Expand Down Expand Up @@ -537,21 +540,21 @@ public KeyInput getActiveKeyboard() {
if (this.activeKeyboard == null) {
setActiveKeyboard("default keyboard");
}
return this.activeKeyboard;
return Require.nonNull("ActiveKeyboard", this.activeKeyboard);
}

public PointerInput getActivePointer() {
if (this.activePointer == null) {
setActivePointer(PointerInput.Kind.MOUSE, "default mouse");
}
return this.activePointer;
return Require.nonNull("ActivePointer", this.activePointer);
}

public WheelInput getActiveWheel() {
if (this.activeWheel == null) {
setActiveWheel("default wheel");
}
return this.activeWheel;
return Require.nonNull("ActiveWheel", this.activeWheel);
}

public Duration getActionDuration() {
Expand Down
2 changes: 2 additions & 0 deletions java/src/org/openqa/selenium/interactions/Pause.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import org.jspecify.annotations.NullMarked;

/** Indicates that a given {@link InputSource} should pause for a given duration. */
@NullMarked
public class Pause extends Interaction implements Encodable {

private final Duration duration;
Expand Down
2 changes: 2 additions & 0 deletions java/src/org/openqa/selenium/interactions/Sequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.jspecify.annotations.NullMarked;

/**
* A sequence of action objects for a given {@link InputSource} for use with the W3C <a
Expand All @@ -30,6 +31,7 @@
* Interaction}s, with the first item in each sequence being executed at the same time, then the
* second, and so on, until all interactions in all sequences have been executed.
*/
@NullMarked
public class Sequence implements Encodable {

private final List<Encodable> actions = new LinkedList<>();
Expand Down
5 changes: 4 additions & 1 deletion java/src/org/openqa/selenium/interactions/WheelInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.WrapsElement;
Expand All @@ -33,11 +35,12 @@
* Models a <a href="https://www.w3.org/TR/webdriver/#dfn-wheel-input-source">wheel input
* source</a>.
*/
@NullMarked
public class WheelInput implements InputSource, Encodable {

private final String name;

public WheelInput(String name) {
public WheelInput(@Nullable String name) {
this.name = Optional.ofNullable(name).orElse(UUID.randomUUID().toString());
}

Expand Down
Loading