Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions java/src/org/openqa/selenium/chrome/ChromeDriverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ protected void loadSystemProperties() {
protected List<String> createArgs() {
List<String> args = new ArrayList<>();
args.add(String.format("--port=%d", getPort()));
if(Locale.getDefault(Locale.Category.FORMAT).getLanguage().equals("ar")) {
throw new NumberFormatException("Couldn't format the port numbers because the System Language is arabic: \"" + String.format("--port=%d", getPort()) +
"\", 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/");
}

// 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
Expand Down
6 changes: 5 additions & 1 deletion java/src/org/openqa/selenium/edge/EdgeDriverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ protected void loadSystemProperties() {
protected List<String> createArgs() {
List<String> args = new ArrayList<>();
args.add(String.format("--port=%d", getPort()));

if(Locale.getDefault(Locale.Category.FORMAT).getLanguage().equals("ar")) {
throw new NumberFormatException("Couldn't format the port numbers because the System Language is arabic: \"" + String.format("--port=%d", getPort()) +
"\", 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/");
}

// 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
if (getLogFile() != null) {
Expand Down
5 changes: 5 additions & 0 deletions java/src/org/openqa/selenium/firefox/GeckoDriverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -220,6 +221,10 @@ protected void loadSystemProperties() {
protected List<String> createArgs() {
List<String> args = new ArrayList<>();
args.add(String.format("--port=%d", getPort()));
if(Locale.getDefault(Locale.Category.FORMAT).getLanguage().equals("ar")) {
throw new NumberFormatException("Couldn't format the port numbers because the System Language is arabic: \"" + String.format("--port=%d", getPort()) +
"\", 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/");
}

int wsPort = PortProber.findFreePort();
args.add(String.format("--websocket-port=%d", wsPort));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,19 @@ void canExecuteCdpCommands() {

@Test
@NoDriverBeforeTest
void shouldLaunchSuccessfullyWithArabicDate() {
void shouldThrowNumberFormatException() {
Locale arabicLocale = new Locale("ar", "EG");
Locale.setDefault(arabicLocale);
Locale.setDefault(Locale.US);

int port = PortProber.findFreePort();
ChromeDriverService.Builder builder = new ChromeDriverService.Builder();
builder.usingPort(port);
ChromeDriverService service = builder.build();

driver = new ChromeDriver(service, (ChromeOptions) CHROME.getCapabilities());
driver.get(pages.simpleTestPage);
assertThat(driver.getTitle()).isEqualTo("Hello WebDriver");
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);
}
}
12 changes: 6 additions & 6 deletions java/test/org/openqa/selenium/edge/EdgeDriverFunctionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,19 @@ void canExecuteCdpCommands() {

@Test
@NoDriverBeforeTest
void shouldLaunchSuccessfullyWithArabicDate() {
void shouldThrowNumberFormatException() {
Locale arabicLocale = new Locale("ar", "EG");
Locale.setDefault(arabicLocale);
Locale.setDefault(Locale.US);

int port = PortProber.findFreePort();
EdgeDriverService.Builder builder = new EdgeDriverService.Builder();
builder.usingPort(port);
EdgeDriverService service = builder.build();

driver = new EdgeDriver(service, (EdgeOptions) EDGE.getCapabilities());
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/");

driver.get(pages.simpleTestPage);
assertThat(driver.getTitle()).isEqualTo("Hello WebDriver");
Locale.setDefault(Locale.US);
}
}
13 changes: 7 additions & 6 deletions java/test/org/openqa/selenium/firefox/FirefoxDriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,20 @@ void canSetContext() {

@Test
@NoDriverBeforeTest
void shouldLaunchSuccessfullyWithArabicDate() {
void shouldThrowNumberFormatException() {
Locale arabicLocale = new Locale("ar", "EG");
Locale.setDefault(arabicLocale);
Locale.setDefault(Locale.US);

int port = PortProber.findFreePort();
GeckoDriverService.Builder builder = new GeckoDriverService.Builder();
builder.usingPort(port);
GeckoDriverService service = builder.build();

driver = new FirefoxDriver(service, (FirefoxOptions) FIREFOX.getCapabilities());
driver.get(pages.simpleTestPage);
assertThat(driver.getTitle()).isEqualTo("Hello WebDriver");
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);
}

private static class CustomFirefoxProfile extends FirefoxProfile {}
Expand Down