Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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
7 changes: 0 additions & 7 deletions .idea/kotlinc.xml

This file was deleted.

3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions java/src/org/openqa/selenium/remote/service/DriverService.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.net.URL;
import java.time.Duration;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -504,6 +505,17 @@ 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:"
+ " \"--port=%d\", 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,23 @@ 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);
}
}
16 changes: 10 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,23 @@ 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);
}
}
18 changes: 12 additions & 6 deletions java/test/org/openqa/selenium/firefox/FirefoxDriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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;
Expand Down Expand Up @@ -272,19 +273,24 @@ 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
24 changes: 24 additions & 0 deletions java/test/org/openqa/selenium/ie/InternetExplorerDriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.awt.*;
import java.time.Duration;
import java.util.Locale;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Capabilities;
Expand All @@ -33,6 +34,7 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.net.PortProber;
import org.openqa.selenium.remote.RemoteWebDriverBuilder;
import org.openqa.selenium.remote.http.ClientConfig;
import org.openqa.selenium.testing.JupiterTestBase;
Expand Down Expand Up @@ -143,6 +145,28 @@ void testPersistentHoverCanBeTurnedOff() throws Exception {
assertThat(item.getText()).isEmpty();
}

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

int port = PortProber.findFreePort();
InternetExplorerDriverService.Builder builder = new InternetExplorerDriverService.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);
}

private WebDriver newIeDriver() {
return new WebDriverBuilder().get();
}
Expand Down
23 changes: 23 additions & 0 deletions java/test/org/openqa/selenium/safari/SafariDriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.Locale;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.SessionNotCreatedException;
Expand Down Expand Up @@ -133,4 +134,26 @@ public void canAttachDebugger() {
localDriver = new WebDriverBuilder().get(new SafariOptions());
((HasDebugger) localDriver).attachDebugger();
}

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