diff --git a/xwiki-platform-core/xwiki-platform-test/pom.xml b/xwiki-platform-core/xwiki-platform-test/pom.xml index 447c754b97310a056a5a30159b1510fffbbee2fb..0597909f30e89f4d59dfdbfc30f1d8ae02faf3a7 100644 --- a/xwiki-platform-core/xwiki-platform-test/pom.xml +++ b/xwiki-platform-core/xwiki-platform-test/pom.xml @@ -32,7 +32,7 @@ <packaging>pom</packaging> <description>XWiki Platform - Test - Parent POM</description> <properties> - <selenium.version>4.7.1</selenium.version> + <selenium.version>4.7.2</selenium.version> <!-- Don't run backward-compatibility checks in test modules since we don't consider them as public APIs --> <xwiki.revapi.skip>true</xwiki.revapi.skip> </properties> diff --git a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-docker/src/main/java/org/xwiki/test/docker/junit5/browser/Browser.java b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-docker/src/main/java/org/xwiki/test/docker/junit5/browser/Browser.java index 23df21ffb6eb111eb8a86ebc0b13fa0f624ac6ff..b9e8eaec2af4d0c86f03df5486e18cdbd8faf2dc 100644 --- a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-docker/src/main/java/org/xwiki/test/docker/junit5/browser/Browser.java +++ b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-docker/src/main/java/org/xwiki/test/docker/junit5/browser/Browser.java @@ -42,12 +42,12 @@ public enum Browser /** * The Firefox Browser. */ - FIREFOX(new FirefoxOptions()), + FIREFOX(buildFirefoxOptions()), /** * The Chrome Browser. */ - CHROME(new ChromeOptions()); + CHROME(buildChromeOptions()); /** * The path where to store the test-resources on the browser container. @@ -64,40 +64,6 @@ public enum Browser Browser(Capabilities capabilities) { this.capabilities = capabilities; - this.forceDefaultCapabilities(); - } - - /** - * Ensure that some capabilities are set as expected for our tests. - */ - private void forceDefaultCapabilities() - { - DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); - LoggingPreferences logPrefs = new LoggingPreferences(); - logPrefs.enable(LogType.BROWSER, Level.ALL); - // By default we want to be able to handle alerts. - desiredCapabilities.setCapability(CapabilityType.SUPPORTS_ALERTS, true); - desiredCapabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE); - desiredCapabilities.setCapability(CapabilityType.UNHANDLED_PROMPT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE); - desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); - this.capabilities = this.capabilities.merge(desiredCapabilities); - - if (this.capabilities instanceof FirefoxOptions) { - FirefoxOptions firefoxOptions = (FirefoxOptions) this.capabilities; - // Create the profile on the fly, mostly for test. - if (firefoxOptions.getProfile() == null) { - firefoxOptions.setProfile(new FirefoxProfile()); - } - // We want to ensure that those events are taking into account. - firefoxOptions.addPreference("dom.disable_beforeunload", false); - } else if (this.capabilities instanceof ChromeOptions) { - ChromeOptions chromeOptions = (ChromeOptions) this.capabilities; - chromeOptions.addArguments( - "--whitelisted-ips", - "--no-sandbox", - "--disable-extensions" - ); - } } /** @@ -116,4 +82,40 @@ public String getTestResourcesPath() { return TEST_RESOURCES_PATH; } + + private static Capabilities buildCommonCapabilities() + { + DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); + // By default, we want to be able to handle alerts. + desiredCapabilities.setCapability(CapabilityType.UNHANDLED_PROMPT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE); + return desiredCapabilities; + } + + private static FirefoxOptions buildFirefoxOptions() + { + FirefoxOptions options = new FirefoxOptions(); + options.merge(buildCommonCapabilities()); + // Create the profile on the fly, mostly for test. + if (options.getProfile() == null) { + options.setProfile(new FirefoxProfile()); + } + // We want to ensure that those events are taking into account. + options.addPreference("dom.disable_beforeunload", false); + return options; + } + + private static ChromeOptions buildChromeOptions() + { + ChromeOptions options = new ChromeOptions(); + options.merge(buildCommonCapabilities()); + LoggingPreferences logPrefs = new LoggingPreferences(); + logPrefs.enable(LogType.BROWSER, Level.ALL); + options.setCapability(ChromeOptions.LOGGING_PREFS, logPrefs); + options.addArguments( + "--whitelisted-ips", + "--no-sandbox", + "--disable-extensions" + ); + return options; + } }