From 279d862a4d457b28bde577076d6f87bdcbc96ce3 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 21 Aug 2014 11:38:22 +0300 Subject: [PATCH] Do not automatically change DesiredCapabilities so equals works the way tests expect Change-Id: I573f0a7f8544742396fcd5927bc3292350754c6d --- .../table/CtrlShiftMultiselectTest.java | 7 +--- .../components/table/SelectAllRowsTest.java | 9 +---- .../com/vaadin/tests/tb3/AbstractTB3Test.java | 37 +++++++++++++++---- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/uitest/src/com/vaadin/tests/components/table/CtrlShiftMultiselectTest.java b/uitest/src/com/vaadin/tests/components/table/CtrlShiftMultiselectTest.java index 255a798594..026d672044 100644 --- a/uitest/src/com/vaadin/tests/components/table/CtrlShiftMultiselectTest.java +++ b/uitest/src/com/vaadin/tests/components/table/CtrlShiftMultiselectTest.java @@ -40,11 +40,8 @@ public class CtrlShiftMultiselectTest extends MultiBrowserTest { } @Override - protected DesiredCapabilities getDesiredCapabilities() { - DesiredCapabilities cap = new DesiredCapabilities( - super.getDesiredCapabilities()); - cap.setCapability("requireWindowFocus", true); - return cap; + protected boolean requireWindowFocusForIE() { + return true; } @Test diff --git a/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java b/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java index 0fc09adf40..d4e8441757 100644 --- a/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java +++ b/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java @@ -35,14 +35,9 @@ import com.vaadin.tests.tb3.MultiBrowserTest; public class SelectAllRowsTest extends MultiBrowserTest { - private final static String TABLE_ROW = "v-table-row"; - @Override - protected DesiredCapabilities getDesiredCapabilities() { - DesiredCapabilities cap = new DesiredCapabilities( - super.getDesiredCapabilities()); - cap.setCapability("requireWindowFocus", true); - return cap; + protected boolean requireWindowFocusForIE() { + return true; } @Override diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 8142c3ae6b..d2313a0709 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -266,12 +266,15 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { private void setupRemoteDriver(DesiredCapabilities capabilities) throws Exception { if (BrowserUtil.isIE(capabilities)) { - capabilities.setCapability( - InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, - requireWindowFocusForIE()); - capabilities.setCapability( - InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, - usePersistentHoverForIE()); + if (requireWindowFocusForIE()) { + capabilities.setCapability( + InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true); + } + if (!usePersistentHoverForIE()) { + capabilities.setCapability( + InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, + false); + } } WebDriver dr = TestBench.createDriver(new RemoteWebDriver(new URL( @@ -383,7 +386,10 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * @param desiredCapabilities */ public void setDesiredCapabilities(DesiredCapabilities desiredCapabilities) { - this.desiredCapabilities = desiredCapabilities; + // Make a copy as the desired capabilities can come from a shared, + // static resource. This will cause all kinds of problems if some test + // modifies the capabilities + this.desiredCapabilities = new DesiredCapabilities(desiredCapabilities); } /** @@ -958,10 +964,25 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * Checks if the given capabilities refer to Internet Explorer 8 * * @param capabilities + * @param version * @return true if the capabilities refer to IE8, false otherwise */ public static boolean isIE8(DesiredCapabilities capabilities) { - return isIE(capabilities) && "8".equals(capabilities.getVersion()); + return isIE(8, capabilities); + } + + /** + * Checks if the given capabilities refer to Internet Explorer of the + * given version + * + * @param capabilities + * @param version + * @return true if the capabilities refer to IE of the given version, + * false otherwise + */ + public static boolean isIE(int version, DesiredCapabilities capabilities) { + return isIE(capabilities) + && ("" + version).equals(capabilities.getVersion()); } /** -- 2.39.5