Bug 4339: If maximizing the browser window does not work with a specific

WebDriver, we now try to set a proper resolution as fallback
This commit is contained in:
Steffen Schaefer committed 2018-07-24 08:19:20 +02:00
1 parent 2839c7431e
commit 5ab1bf1815
2 files changed
+14

No files matched your search

@@ -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<SeleniumJUnit4ClassRunner> {
} 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();
@@ -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();
}