Skip to content

Commit fe86936

Browse files
committed
Add Formatting with Locale.ROOT for the port at :
- ChromeDriverService - EdgeDriverService - GeckoDriverService - InternetExplorerDriverService and to the getUrl method at: - DriverService Refactor the Arabic Tests in the following accordingly: - ChromeDriverFunctionalTest - EdgeDriverFunctionalTest - FirefoxDriverTest - InternetExplorerDriverTest - SafariDriverTest
1 parent 889b309 commit fe86936

File tree

10 files changed

+17
-66
lines changed

10 files changed

+17
-66
lines changed

java/src/org/openqa/selenium/chrome/ChromeDriverService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ protected void loadSystemProperties() {
284284
@Override
285285
protected List<String> createArgs() {
286286
List<String> args = new ArrayList<>();
287-
args.add(String.format("--port=%d", getPort()));
287+
args.add(String.format(Locale.ROOT, "--port=%d", getPort()));
288288

289289
// Readable timestamp and append logs only work if log path is specified in args
290290
// Cannot use logOutput because goog:loggingPrefs requires --log-path get sent

java/src/org/openqa/selenium/edge/EdgeDriverService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ protected void loadSystemProperties() {
278278
@Override
279279
protected List<String> createArgs() {
280280
List<String> args = new ArrayList<>();
281-
args.add(String.format("--port=%d", getPort()));
281+
args.add(String.format(Locale.ROOT, "--port=%d", getPort()));
282282

283283
// Readable timestamp and append logs only work if log path is specified in args
284284
// Cannot use logOutput because goog:loggingPrefs requires --log-path get sent

java/src/org/openqa/selenium/firefox/GeckoDriverService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.Arrays;
3131
import java.util.HashMap;
3232
import java.util.List;
33+
import java.util.Locale;
3334
import java.util.Map;
3435
import org.openqa.selenium.Capabilities;
3536
import org.openqa.selenium.WebDriverException;
@@ -219,7 +220,7 @@ protected void loadSystemProperties() {
219220
@Override
220221
protected List<String> createArgs() {
221222
List<String> args = new ArrayList<>();
222-
args.add(String.format("--port=%d", getPort()));
223+
args.add(String.format(Locale.ROOT, "--port=%d", getPort()));
223224

224225
int wsPort = PortProber.findFreePort();
225226
args.add(String.format("--websocket-port=%d", wsPort));

java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.ArrayList;
2929
import java.util.HashMap;
3030
import java.util.List;
31+
import java.util.Locale;
3132
import java.util.Map;
3233
import org.openqa.selenium.Capabilities;
3334
import org.openqa.selenium.WebDriverException;
@@ -217,7 +218,7 @@ protected void loadSystemProperties() {
217218
@Override
218219
protected List<String> createArgs() {
219220
List<String> args = new ArrayList<>();
220-
args.add(String.format("--port=%d", getPort()));
221+
args.add(String.format(Locale.ROOT, "--port=%d", getPort()));
221222

222223
if (logLevel != null) {
223224
args.add(String.format("--log-level=%s", logLevel));

java/src/org/openqa/selenium/remote/service/DriverService.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ protected Map<String, String> getEnvironment() {
138138
}
139139

140140
protected URL getUrl(int port) throws IOException {
141-
return new URL(String.format("http://localhost:%d", port));
141+
return new URL(String.format(Locale.ROOT,"http://localhost:%d", port));
142142
}
143143

144144
protected Capabilities getDefaultDriverOptions() {
@@ -505,17 +505,6 @@ public DS build() {
505505
port = PortProber.findFreePort();
506506
}
507507

508-
if (Locale.getDefault(Locale.Category.FORMAT).getLanguage().equals("ar")) {
509-
throw new NumberFormatException(
510-
String.format(
511-
"Couldn't format the port numbers because the System Language is arabic: \""
512-
+ String.format("--port=%d", port)
513-
+ "\", please make sure to add the required arguments \"-Duser.language=en"
514-
+ " -Duser.region=US\" to your JVM, for more info please visit :\n"
515-
+ " https://www.selenium.dev/documentation/webdriver/browsers/",
516-
getPort()));
517-
}
518-
519508
if (timeout == null) {
520509
timeout = getDefaultTimeout();
521510
}

java/test/org/openqa/selenium/chrome/ChromeDriverFunctionalTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,22 +204,14 @@ void canExecuteCdpCommands() {
204204

205205
@Test
206206
@NoDriverBeforeTest
207-
void shouldThrowNumberFormatException() {
207+
void shouldLaunchSuccessfullyWithArabicDate() {
208208
Locale arabicLocale = new Locale("ar", "EG");
209209
Locale.setDefault(arabicLocale);
210210

211211
int port = PortProber.findFreePort();
212212
ChromeDriverService.Builder builder = new ChromeDriverService.Builder();
213213
builder.usingPort(port);
214-
215-
assertThatExceptionOfType(NumberFormatException.class)
216-
.isThrownBy(builder::build)
217-
.withMessage(
218-
"Couldn't format the port numbers because the System Language is arabic: \""
219-
+ String.format("--port=%d", port)
220-
+ "\", please make sure to add the required arguments \"-Duser.language=en"
221-
+ " -Duser.region=US\" to your JVM, for more info please visit :\n"
222-
+ " https://www.selenium.dev/documentation/webdriver/browsers/");
214+
builder.build();
223215

224216
Locale.setDefault(Locale.US);
225217
}

java/test/org/openqa/selenium/edge/EdgeDriverFunctionalTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,22 +198,14 @@ void canExecuteCdpCommands() {
198198

199199
@Test
200200
@NoDriverBeforeTest
201-
void shouldThrowNumberFormatException() {
201+
void shouldLaunchSuccessfullyWithArabicDate() {
202202
Locale arabicLocale = new Locale("ar", "EG");
203203
Locale.setDefault(arabicLocale);
204204

205205
int port = PortProber.findFreePort();
206206
EdgeDriverService.Builder builder = new EdgeDriverService.Builder();
207207
builder.usingPort(port);
208-
209-
assertThatExceptionOfType(NumberFormatException.class)
210-
.isThrownBy(builder::build)
211-
.withMessage(
212-
"Couldn't format the port numbers because the System Language is arabic: \""
213-
+ String.format("--port=%d", port)
214-
+ "\", please make sure to add the required arguments \"-Duser.language=en"
215-
+ " -Duser.region=US\" to your JVM, for more info please visit :\n"
216-
+ " https://www.selenium.dev/documentation/webdriver/browsers/");
208+
builder.build();
217209

218210
Locale.setDefault(Locale.US);
219211
}

java/test/org/openqa/selenium/firefox/FirefoxDriverTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,22 +273,14 @@ void canSetContext() {
273273

274274
@Test
275275
@NoDriverBeforeTest
276-
void shouldThrowNumberFormatException() {
276+
void shouldLaunchSuccessfullyWithArabicDate() {
277277
Locale arabicLocale = new Locale("ar", "EG");
278278
Locale.setDefault(arabicLocale);
279279

280280
int port = PortProber.findFreePort();
281281
GeckoDriverService.Builder builder = new GeckoDriverService.Builder();
282282
builder.usingPort(port);
283-
284-
assertThatExceptionOfType(NumberFormatException.class)
285-
.isThrownBy(builder::build)
286-
.withMessage(
287-
"Couldn't format the port numbers because the System Language is arabic: \""
288-
+ String.format("--port=%d", port)
289-
+ "\", please make sure to add the required arguments \"-Duser.language=en"
290-
+ " -Duser.region=US\" to your JVM, for more info please visit :\n"
291-
+ " https://www.selenium.dev/documentation/webdriver/browsers/");
283+
builder.build();
292284

293285
Locale.setDefault(Locale.US);
294286
}

java/test/org/openqa/selenium/ie/InternetExplorerDriverTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,14 @@ void testPersistentHoverCanBeTurnedOff() throws Exception {
147147

148148
@Test
149149
@NoDriverBeforeTest
150-
void shouldThrowNumberFormatException() {
150+
void shouldLaunchSuccessfullyWithArabicDate() {
151151
Locale arabicLocale = new Locale("ar", "EG");
152152
Locale.setDefault(arabicLocale);
153153

154154
int port = PortProber.findFreePort();
155155
InternetExplorerDriverService.Builder builder = new InternetExplorerDriverService.Builder();
156156
builder.usingPort(port);
157-
158-
assertThatExceptionOfType(NumberFormatException.class)
159-
.isThrownBy(builder::build)
160-
.withMessage(
161-
"Couldn't format the port numbers because the System Language is arabic: \""
162-
+ String.format("--port=%d", port)
163-
+ "\", please make sure to add the required arguments \"-Duser.language=en"
164-
+ " -Duser.region=US\" to your JVM, for more info please visit :\n"
165-
+ " https://www.selenium.dev/documentation/webdriver/browsers/");
157+
builder.build();
166158

167159
Locale.setDefault(Locale.US);
168160
}

java/test/org/openqa/selenium/safari/SafariDriverTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,14 @@ public void canAttachDebugger() {
137137

138138
@Test
139139
@NoDriverBeforeTest
140-
void shouldThrowNumberFormatException() {
140+
void shouldLaunchSuccessfullyWithArabicDate() {
141141
Locale arabicLocale = new Locale("ar", "EG");
142142
Locale.setDefault(arabicLocale);
143143

144144
int port = PortProber.findFreePort();
145145
SafariDriverService.Builder builder = new SafariDriverService.Builder();
146146
builder.usingPort(port);
147-
148-
assertThatExceptionOfType(NumberFormatException.class)
149-
.isThrownBy(builder::build)
150-
.withMessage(
151-
"Couldn't format the port numbers because the System Language is arabic: \""
152-
+ String.format("--port=%d", port)
153-
+ "\", please make sure to add the required arguments \"-Duser.language=en"
154-
+ " -Duser.region=US\" to your JVM, for more info please visit :\n"
155-
+ " https://www.selenium.dev/documentation/webdriver/browsers/");
147+
builder.build();
156148

157149
Locale.setDefault(Locale.US);
158150
}

0 commit comments

Comments
 (0)