Skip to content

Commit d0a0df9

Browse files
committed
[java] make the action movement methods specify the button number
1 parent 190a8fb commit d0a0df9

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

‎java/src/org/openqa/selenium/interactions/Actions.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT;
2121
import static org.openqa.selenium.interactions.PointerInput.MouseButton.RIGHT;
2222

23+
import org.openqa.selenium.Dimension;
2324
import org.openqa.selenium.Keys;
25+
import org.openqa.selenium.Rectangle;
2426
import org.openqa.selenium.UnsupportedCommandException;
2527
import org.openqa.selenium.WebDriver;
2628
import org.openqa.selenium.WebElement;
@@ -420,9 +422,6 @@ public Actions moveToElement(WebElement target, int xOffset, int yOffset) {
420422
action.addAction(new MoveToOffsetAction(jsonMouse, (Locatable) target, xOffset, yOffset));
421423
}
422424

423-
// Of course, this is the offset from the centre of the element. We have no idea what the width
424-
// and height are once we execute this method.
425-
LOG.info("When using the W3C Action commands, offsets are from the element's in-view center point");
426425
return moveInTicks(target, xOffset, yOffset);
427426
}
428427

‎java/src/org/openqa/selenium/interactions/PointerInput.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,32 @@ public Interaction createPointerDown(int button) {
7979
return new PointerPress(this, PointerPress.Direction.DOWN, button);
8080
}
8181

82+
/**
83+
* @deprecated always use the method with the button
84+
*/
85+
@Deprecated
8286
public Interaction createPointerDown(PointerEventProperties eventProperties) {
83-
return new PointerPress(this, PointerPress.Direction.DOWN, eventProperties);
87+
return createPointerDown(0, eventProperties);
88+
}
89+
90+
public Interaction createPointerDown(int button, PointerEventProperties eventProperties) {
91+
return new PointerPress(this, PointerPress.Direction.DOWN, button, eventProperties);
8492
}
8593

8694
public Interaction createPointerUp(int button) {
8795
return new PointerPress(this, PointerPress.Direction.UP, button);
8896
}
8997

98+
/**
99+
* @deprecated always use the method with the button
100+
*/
101+
@Deprecated
90102
public Interaction createPointerUp(PointerEventProperties eventProperties) {
91-
return new PointerPress(this, PointerPress.Direction.UP, eventProperties);
103+
return createPointerUp(0, eventProperties);
104+
}
105+
106+
public Interaction createPointerUp(int button, PointerEventProperties eventProperties) {
107+
return new PointerPress(this, PointerPress.Direction.UP, button, eventProperties);
92108
}
93109

94110
private static class PointerPress extends Interaction implements Encodable {
@@ -110,9 +126,17 @@ public PointerPress(InputSource source, Direction direction, int button) {
110126
this.eventProperties = new PointerEventProperties();
111127
}
112128

129+
/**
130+
* @deprecated always use the constructor with the button
131+
*/
132+
@Deprecated
113133
public PointerPress(InputSource source, Direction direction, PointerEventProperties eventProperties) {
134+
this(source, direction, 0, eventProperties);
135+
}
136+
137+
public PointerPress(InputSource source, Direction direction, int button, PointerEventProperties eventProperties) {
114138
super(source);
115-
this.button = 0;
139+
this.button = button;
116140
this.eventProperties = Require.nonNull("pointer event properties", eventProperties);
117141
this.direction = Require.nonNull("Direction of press", direction);
118142
}
@@ -212,6 +236,8 @@ public enum MouseButton {
212236
LEFT(0),
213237
MIDDLE(1),
214238
RIGHT(2),
239+
BACK(3),
240+
FORWARD(4),
215241
;
216242

217243
private final int button;

0 commit comments

Comments
 (0)