Skip to content

Commit 409699b

Browse files
asashourlukeis
authored andcommitted
HtmlUnitMouse: no need to .focus()
Previously, HtmlUnit didn't correctly handle 'focus' event on .click()ing an element, but now it does. This change fixes a test case Also, the constructor with HtmlUnitDriver is not needed, so it is deprecated. Signed-off-by: Luke Inman-Semerau <[email protected]>
1 parent c181d39 commit 409699b

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

java/client/src/org/openqa/selenium/htmlunit/HtmlUnitDriver.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ protected void get(URL fullUrl) {
554554

555555
private void resetKeyboardAndMouseState() {
556556
keyboard = new HtmlUnitKeyboard(this);
557-
mouse = new HtmlUnitMouse(this, keyboard);
557+
mouse = new HtmlUnitMouse(keyboard);
558558
}
559559

560560
protected void pickWindow() {

java/client/src/org/openqa/selenium/htmlunit/HtmlUnitMouse.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import com.gargoylesoftware.htmlunit.ScriptException;
2828
import com.gargoylesoftware.htmlunit.html.HtmlElement;
29-
import com.gargoylesoftware.htmlunit.html.HtmlInput;
3029
import com.gargoylesoftware.htmlunit.javascript.host.event.MouseEvent;
3130
import com.google.common.base.Preconditions;
3231

@@ -35,15 +34,21 @@
3534
*
3635
*/
3736
public class HtmlUnitMouse implements Mouse {
38-
private final HtmlUnitDriver parent;
3937
private final HtmlUnitKeyboard keyboard;
4038
private HtmlElement currentActiveElement = null;
4139

42-
public HtmlUnitMouse(HtmlUnitDriver parent, HtmlUnitKeyboard keyboard) {
43-
this.parent = parent;
40+
public HtmlUnitMouse(HtmlUnitKeyboard keyboard) {
4441
this.keyboard = keyboard;
4542
}
4643

44+
/**
45+
* @deprecated as of 2.47.0, please use {@link #HtmlUnitMouse(HtmlUnitKeyboard)} instead
46+
*/
47+
@Deprecated
48+
public HtmlUnitMouse(HtmlUnitDriver parent, HtmlUnitKeyboard keyboard) {
49+
this(keyboard);
50+
}
51+
4752
private HtmlElement getElementForOperation(Coordinates potentialCoordinates) {
4853
if (potentialCoordinates != null) {
4954
return (HtmlElement) potentialCoordinates.getAuxiliary();
@@ -64,10 +69,6 @@ public void click(Coordinates elementCoordinates) {
6469
moveOutIfNeeded(element);
6570

6671
try {
67-
if (!(element instanceof HtmlInput)) {
68-
element.focus();
69-
}
70-
7172
element.mouseOver();
7273
element.mouseMove();
7374

java/client/test/org/openqa/selenium/CorrectEventFiringTest.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,17 @@
3434
import static org.openqa.selenium.testing.Ignore.Driver.MARIONETTE;
3535
import static org.openqa.selenium.testing.Ignore.Driver.SAFARI;
3636

37+
import java.io.File;
38+
import java.io.IOException;
39+
import java.util.List;
40+
3741
import org.junit.Test;
3842
import org.openqa.selenium.testing.Ignore;
3943
import org.openqa.selenium.testing.JUnit4TestBase;
4044
import org.openqa.selenium.testing.JavascriptEnabled;
41-
import org.openqa.selenium.testing.NotYetImplemented;
4245
import org.openqa.selenium.testing.TestUtilities;
4346
import org.openqa.selenium.testing.drivers.SauceDriver;
4447

45-
import java.io.File;
46-
import java.io.IOException;
47-
import java.util.List;
48-
4948
public class CorrectEventFiringTest extends JUnit4TestBase {
5049

5150
@Ignore(value = {MARIONETTE})
@@ -126,7 +125,6 @@ public void testShouldNotThrowIfEventHandlerThrows() {
126125

127126
@Ignore(MARIONETTE)
128127
@JavascriptEnabled
129-
@NotYetImplemented(HTMLUNIT)
130128
@Test
131129
public void testShouldFireEventsInTheRightOrder() {
132130
driver.get(pages.javascriptPage);

0 commit comments

Comments
 (0)