From 5ab1bf18150bd83b2bc5f2972b4f4598bb44fbf8 Mon Sep 17 00:00:00 2001 From: Steffen Schaefer Date: Tue, 24 Jul 2018 08:19:20 +0200 Subject: [PATCH] Bug 4339: If maximizing the browser window does not work with a specific WebDriver, we now try to set a proper resolution as fallback --- .../src/com/sap/sailing/selenium/core/SeleniumRunner.java | 7 +++++++ .../test/leaderboard/TestLeaderboardConfiguration.java | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/core/SeleniumRunner.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/core/SeleniumRunner.java index fb812c22bcd..8bad082ea83 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/core/SeleniumRunner.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/core/SeleniumRunner.java @@ -20,6 +20,7 @@ import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.InitializationError; import org.junit.runners.model.TestClass; import org.openqa.selenium.Capabilities; +import org.openqa.selenium.Dimension; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.DesiredCapabilities; @@ -181,6 +182,12 @@ public class SeleniumRunner extends ParentRunner { } catch (Exception e) { // Depending on the combination of OS and WebDriver implementation this may fail // e.g. chrome with xvfb can't do this successfully. + try { + // Trying to set a proper screen size as fallback that should usable with all modern screens + driver.manage().window().setSize(new Dimension(1440, 900)); + } catch (Exception exc) { + // In this case we just can't change the window + } } File screenshots = resolveScreenshotFolder(); diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/leaderboard/TestLeaderboardConfiguration.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/leaderboard/TestLeaderboardConfiguration.java index 0d7e4497bf7..08f1b2660e9 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/leaderboard/TestLeaderboardConfiguration.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/leaderboard/TestLeaderboardConfiguration.java @@ -11,6 +11,7 @@ import java.util.function.BiConsumer; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import org.openqa.selenium.Dimension; import com.sap.sailing.selenium.core.WebDriverWindow; import com.sap.sailing.selenium.core.WindowManager; @@ -194,6 +195,12 @@ public class TestLeaderboardConfiguration extends AbstractSeleniumTest { getWebDriver().manage().window().maximize(); } catch (Exception e) { // maximizing isn't supported on all Systems / WebDriver implementations + try { + // Trying to set a proper screen size as fallback that should usable with all modern screens + getWebDriver().manage().window().setSize(new Dimension(1440, 900)); + } catch (Exception exc) { + // In this case we just can't change the window + } } finally { defaultWindow.switchToWindow(); }