diff --git a/java/src/org/openqa/selenium/chrome/ChromeDriverService.java b/java/src/org/openqa/selenium/chrome/ChromeDriverService.java index d6beaa0b69489..3b1d61446df8f 100644 --- a/java/src/org/openqa/selenium/chrome/ChromeDriverService.java +++ b/java/src/org/openqa/selenium/chrome/ChromeDriverService.java @@ -284,7 +284,7 @@ protected void loadSystemProperties() { @Override protected List createArgs() { List args = new ArrayList<>(); - args.add(String.format("--port=%d", getPort())); + args.add(String.format(Locale.ROOT, "--port=%d", getPort())); // Readable timestamp and append logs only work if log path is specified in args // Cannot use logOutput because goog:loggingPrefs requires --log-path get sent diff --git a/java/src/org/openqa/selenium/edge/EdgeDriverService.java b/java/src/org/openqa/selenium/edge/EdgeDriverService.java index 0e3c252087882..799e3c3759d95 100644 --- a/java/src/org/openqa/selenium/edge/EdgeDriverService.java +++ b/java/src/org/openqa/selenium/edge/EdgeDriverService.java @@ -278,7 +278,7 @@ protected void loadSystemProperties() { @Override protected List createArgs() { List args = new ArrayList<>(); - args.add(String.format("--port=%d", getPort())); + args.add(String.format(Locale.ROOT, "--port=%d", getPort())); // Readable timestamp and append logs only work if log path is specified in args // Cannot use logOutput because goog:loggingPrefs requires --log-path get sent diff --git a/java/src/org/openqa/selenium/firefox/GeckoDriverService.java b/java/src/org/openqa/selenium/firefox/GeckoDriverService.java index c2a73827046b8..7602085d506f6 100644 --- a/java/src/org/openqa/selenium/firefox/GeckoDriverService.java +++ b/java/src/org/openqa/selenium/firefox/GeckoDriverService.java @@ -30,6 +30,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; @@ -219,7 +220,7 @@ protected void loadSystemProperties() { @Override protected List createArgs() { List args = new ArrayList<>(); - args.add(String.format("--port=%d", getPort())); + args.add(String.format(Locale.ROOT, "--port=%d", getPort())); int wsPort = PortProber.findFreePort(); args.add(String.format("--websocket-port=%d", wsPort)); diff --git a/java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java b/java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java index 506da630d991a..e66f0eab35a81 100644 --- a/java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java +++ b/java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; @@ -217,7 +218,7 @@ protected void loadSystemProperties() { @Override protected List createArgs() { List args = new ArrayList<>(); - args.add(String.format("--port=%d", getPort())); + args.add(String.format(Locale.ROOT, "--port=%d", getPort())); if (logLevel != null) { args.add(String.format("--log-level=%s", logLevel)); diff --git a/java/src/org/openqa/selenium/remote/service/DriverService.java b/java/src/org/openqa/selenium/remote/service/DriverService.java index b0cb2bac5c39f..d957b694fb004 100644 --- a/java/src/org/openqa/selenium/remote/service/DriverService.java +++ b/java/src/org/openqa/selenium/remote/service/DriverService.java @@ -138,7 +138,7 @@ protected Map getEnvironment() { } protected URL getUrl(int port) throws IOException { - return new URL(String.format("http://localhost:%d", port)); + return new URL(String.format(Locale.ROOT, "http://localhost:%d", port)); } protected Capabilities getDefaultDriverOptions() { @@ -505,17 +505,6 @@ public DS build() { port = PortProber.findFreePort(); } - if (Locale.getDefault(Locale.Category.FORMAT).getLanguage().equals("ar")) { - throw new NumberFormatException( - String.format( - "Couldn't format the port numbers because the System Language is arabic: \"" - + String.format("--port=%d", port) - + "\", please make sure to add the required arguments \"-Duser.language=en" - + " -Duser.region=US\" to your JVM, for more info please visit :\n" - + " https://www.selenium.dev/documentation/webdriver/browsers/", - getPort())); - } - if (timeout == null) { timeout = getDefaultTimeout(); } diff --git a/java/test/org/openqa/selenium/chrome/ChromeDriverFunctionalTest.java b/java/test/org/openqa/selenium/chrome/ChromeDriverFunctionalTest.java index 6be2366ebf372..ce0d823408d00 100644 --- a/java/test/org/openqa/selenium/chrome/ChromeDriverFunctionalTest.java +++ b/java/test/org/openqa/selenium/chrome/ChromeDriverFunctionalTest.java @@ -204,23 +204,20 @@ void canExecuteCdpCommands() { @Test @NoDriverBeforeTest - void shouldThrowNumberFormatException() { - Locale arabicLocale = new Locale("ar", "EG"); - Locale.setDefault(arabicLocale); - - int port = PortProber.findFreePort(); - ChromeDriverService.Builder builder = new ChromeDriverService.Builder(); - builder.usingPort(port); - - assertThatExceptionOfType(NumberFormatException.class) - .isThrownBy(builder::build) - .withMessage( - "Couldn't format the port numbers because the System Language is arabic: \"" - + String.format("--port=%d", port) - + "\", please make sure to add the required arguments \"-Duser.language=en" - + " -Duser.region=US\" to your JVM, for more info please visit :\n" - + " https://www.selenium.dev/documentation/webdriver/browsers/"); - - Locale.setDefault(Locale.US); + void shouldLaunchSuccessfullyWithArabicDate() { + try { + Locale arabicLocale = new Locale("ar", "EG"); + Locale.setDefault(arabicLocale); + + int port = PortProber.findFreePort(); + ChromeDriverService.Builder builder = new ChromeDriverService.Builder(); + builder.usingPort(port); + builder.build(); + + } catch (Exception e) { + throw e; + } finally { + Locale.setDefault(Locale.US); + } } } diff --git a/java/test/org/openqa/selenium/edge/EdgeDriverFunctionalTest.java b/java/test/org/openqa/selenium/edge/EdgeDriverFunctionalTest.java index a2fa5a38d0539..82fab3ccf1602 100644 --- a/java/test/org/openqa/selenium/edge/EdgeDriverFunctionalTest.java +++ b/java/test/org/openqa/selenium/edge/EdgeDriverFunctionalTest.java @@ -198,23 +198,20 @@ void canExecuteCdpCommands() { @Test @NoDriverBeforeTest - void shouldThrowNumberFormatException() { - Locale arabicLocale = new Locale("ar", "EG"); - Locale.setDefault(arabicLocale); - - int port = PortProber.findFreePort(); - EdgeDriverService.Builder builder = new EdgeDriverService.Builder(); - builder.usingPort(port); - - assertThatExceptionOfType(NumberFormatException.class) - .isThrownBy(builder::build) - .withMessage( - "Couldn't format the port numbers because the System Language is arabic: \"" - + String.format("--port=%d", port) - + "\", please make sure to add the required arguments \"-Duser.language=en" - + " -Duser.region=US\" to your JVM, for more info please visit :\n" - + " https://www.selenium.dev/documentation/webdriver/browsers/"); - - Locale.setDefault(Locale.US); + void shouldLaunchSuccessfullyWithArabicDate() { + try { + Locale arabicLocale = new Locale("ar", "EG"); + Locale.setDefault(arabicLocale); + + int port = PortProber.findFreePort(); + EdgeDriverService.Builder builder = new EdgeDriverService.Builder(); + builder.usingPort(port); + builder.build(); + + } catch (Exception e) { + throw e; + } finally { + Locale.setDefault(Locale.US); + } } } diff --git a/java/test/org/openqa/selenium/firefox/FirefoxDriverTest.java b/java/test/org/openqa/selenium/firefox/FirefoxDriverTest.java index 85e0a7fe1c398..bfc92e800f6a8 100644 --- a/java/test/org/openqa/selenium/firefox/FirefoxDriverTest.java +++ b/java/test/org/openqa/selenium/firefox/FirefoxDriverTest.java @@ -18,7 +18,6 @@ package org.openqa.selenium.firefox; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assumptions.assumeTrue; @@ -273,24 +272,21 @@ void canSetContext() { @Test @NoDriverBeforeTest - void shouldThrowNumberFormatException() { - Locale arabicLocale = new Locale("ar", "EG"); - Locale.setDefault(arabicLocale); - - int port = PortProber.findFreePort(); - GeckoDriverService.Builder builder = new GeckoDriverService.Builder(); - builder.usingPort(port); - - assertThatExceptionOfType(NumberFormatException.class) - .isThrownBy(builder::build) - .withMessage( - "Couldn't format the port numbers because the System Language is arabic: \"" - + String.format("--port=%d", port) - + "\", please make sure to add the required arguments \"-Duser.language=en" - + " -Duser.region=US\" to your JVM, for more info please visit :\n" - + " https://www.selenium.dev/documentation/webdriver/browsers/"); - - Locale.setDefault(Locale.US); + void shouldLaunchSuccessfullyWithArabicDate() { + try { + Locale arabicLocale = new Locale("ar", "EG"); + Locale.setDefault(arabicLocale); + + int port = PortProber.findFreePort(); + GeckoDriverService.Builder builder = new GeckoDriverService.Builder(); + builder.usingPort(port); + builder.build(); + + } catch (Exception e) { + throw e; + } finally { + Locale.setDefault(Locale.US); + } } private static class CustomFirefoxProfile extends FirefoxProfile {} diff --git a/java/test/org/openqa/selenium/ie/InternetExplorerDriverTest.java b/java/test/org/openqa/selenium/ie/InternetExplorerDriverTest.java index c93e1361195cf..70ade3fbe332f 100644 --- a/java/test/org/openqa/selenium/ie/InternetExplorerDriverTest.java +++ b/java/test/org/openqa/selenium/ie/InternetExplorerDriverTest.java @@ -147,24 +147,21 @@ void testPersistentHoverCanBeTurnedOff() throws Exception { @Test @NoDriverBeforeTest - void shouldThrowNumberFormatException() { - Locale arabicLocale = new Locale("ar", "EG"); - Locale.setDefault(arabicLocale); + void shouldLaunchSuccessfullyWithArabicDate() { + try { + Locale arabicLocale = new Locale("ar", "EG"); + Locale.setDefault(arabicLocale); - int port = PortProber.findFreePort(); - InternetExplorerDriverService.Builder builder = new InternetExplorerDriverService.Builder(); - builder.usingPort(port); + int port = PortProber.findFreePort(); + InternetExplorerDriverService.Builder builder = new InternetExplorerDriverService.Builder(); + builder.usingPort(port); + builder.build(); - assertThatExceptionOfType(NumberFormatException.class) - .isThrownBy(builder::build) - .withMessage( - "Couldn't format the port numbers because the System Language is arabic: \"" - + String.format("--port=%d", port) - + "\", please make sure to add the required arguments \"-Duser.language=en" - + " -Duser.region=US\" to your JVM, for more info please visit :\n" - + " https://www.selenium.dev/documentation/webdriver/browsers/"); - - Locale.setDefault(Locale.US); + } catch (Exception e) { + throw e; + } finally { + Locale.setDefault(Locale.US); + } } private WebDriver newIeDriver() { diff --git a/java/test/org/openqa/selenium/safari/SafariDriverTest.java b/java/test/org/openqa/selenium/safari/SafariDriverTest.java index 6312c0ad1e211..15118a013a6d1 100644 --- a/java/test/org/openqa/selenium/safari/SafariDriverTest.java +++ b/java/test/org/openqa/selenium/safari/SafariDriverTest.java @@ -137,23 +137,20 @@ public void canAttachDebugger() { @Test @NoDriverBeforeTest - void shouldThrowNumberFormatException() { - Locale arabicLocale = new Locale("ar", "EG"); - Locale.setDefault(arabicLocale); - - int port = PortProber.findFreePort(); - SafariDriverService.Builder builder = new SafariDriverService.Builder(); - builder.usingPort(port); - - assertThatExceptionOfType(NumberFormatException.class) - .isThrownBy(builder::build) - .withMessage( - "Couldn't format the port numbers because the System Language is arabic: \"" - + String.format("--port=%d", port) - + "\", please make sure to add the required arguments \"-Duser.language=en" - + " -Duser.region=US\" to your JVM, for more info please visit :\n" - + " https://www.selenium.dev/documentation/webdriver/browsers/"); - - Locale.setDefault(Locale.US); + void shouldLaunchSuccessfullyWithArabicDate() { + try { + Locale arabicLocale = new Locale("ar", "EG"); + Locale.setDefault(arabicLocale); + + int port = PortProber.findFreePort(); + SafariDriverService.Builder builder = new SafariDriverService.Builder(); + builder.usingPort(port); + builder.build(); + + } catch (Exception e) { + throw e; + } finally { + Locale.setDefault(Locale.US); + } } }