Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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
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,12 @@ 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,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);
}
}
14 changes: 8 additions & 6 deletions java/test/org/openqa/selenium/firefox/FirefoxDriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.mockito.Mockito.atLeastOnce;
Expand Down Expand Up @@ -272,19 +273,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
21 changes: 21 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,8 @@

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 +35,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 +146,24 @@ 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
20 changes: 20 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,8 @@
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 +135,22 @@ 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);
}
}
Loading