Skip to content

Commit 02744ac

Browse files
committed
[java] Fixing ChromeOptionsFunctionalTest and formatting files
1 parent 0f0f706 commit 02744ac

File tree

7 files changed

+33
-30
lines changed

7 files changed

+33
-30
lines changed

java/src/org/openqa/selenium/WebDriverException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public class WebDriverException extends RuntimeException {
2828

2929
public static final String SESSION_ID = "Session ID";
3030
public static final String DRIVER_INFO = "Driver info";
31-
protected static final String BASE_SUPPORT_URL = "https://www.selenium.dev/documentation/webdriver/troubleshooting/errors";
31+
protected static final String BASE_SUPPORT_URL =
32+
"https://www.selenium.dev/documentation/webdriver/troubleshooting/errors";
3233

3334
private final Map<String, String> extraInfo = new ConcurrentHashMap<>();
3435

java/src/org/openqa/selenium/remote/NoSuchDriverException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
import org.openqa.selenium.remote.service.DriverService;
2323

2424
/**
25-
* Thrown by {@link org.openqa.selenium.remote.service.DriverFinder#getPath(DriverService, Capabilities)}.
25+
* Thrown by {@link org.openqa.selenium.remote.service.DriverFinder#getPath(DriverService,
26+
* Capabilities)}.
2627
*/
2728
public class NoSuchDriverException extends WebDriverException {
2829

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ public static String getPath(DriverService service, Capabilities options) {
2626
try {
2727
exePath = SeleniumManager.getInstance().getDriverPath(options);
2828
} catch (Exception e) {
29-
throw new NoSuchDriverException(String.format(
30-
"Unable to obtain: %s", options), e);
29+
throw new NoSuchDriverException(String.format("Unable to obtain: %s", options), e);
3130
}
3231
}
3332

@@ -37,7 +36,8 @@ public static String getPath(DriverService service, Capabilities options) {
3736
} else if (!new File(exePath).exists()) {
3837
message = String.format("%s located at %s, but invalid", service.getDriverName(), exePath);
3938
} else if (!new File(exePath).canExecute()) {
40-
message = String.format("%s located at %s, cannot be executed", service.getDriverName(), exePath);
39+
message =
40+
String.format("%s located at %s, cannot be executed", service.getDriverName(), exePath);
4141
} else {
4242
return exePath;
4343
}

java/test/org/openqa/selenium/ClickTest.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@
1717

1818
package org.openqa.selenium;
1919

20-
import org.junit.jupiter.api.BeforeEach;
21-
import org.junit.jupiter.api.Test;
22-
import org.openqa.selenium.testing.Ignore;
23-
import org.openqa.selenium.testing.JupiterTestBase;
24-
import org.openqa.selenium.testing.NoDriverAfterTest;
25-
import org.openqa.selenium.testing.NotYetImplemented;
26-
import org.openqa.selenium.testing.SwitchToTopAfterTest;
27-
28-
import java.util.Set;
29-
3020
import static org.assertj.core.api.Assertions.assertThat;
3121
import static org.openqa.selenium.WaitingConditions.newWindowIsOpened;
3222
import static org.openqa.selenium.WaitingConditions.pageSourceToContain;
@@ -35,6 +25,15 @@
3525
import static org.openqa.selenium.testing.drivers.Browser.IE;
3626
import static org.openqa.selenium.testing.drivers.Browser.SAFARI;
3727

28+
import java.util.Set;
29+
import org.junit.jupiter.api.BeforeEach;
30+
import org.junit.jupiter.api.Test;
31+
import org.openqa.selenium.testing.Ignore;
32+
import org.openqa.selenium.testing.JupiterTestBase;
33+
import org.openqa.selenium.testing.NoDriverAfterTest;
34+
import org.openqa.selenium.testing.NotYetImplemented;
35+
import org.openqa.selenium.testing.SwitchToTopAfterTest;
36+
3837
class ClickTest extends JupiterTestBase {
3938

4039
@BeforeEach

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.openqa.selenium.By;
3030
import org.openqa.selenium.WebElement;
3131
import org.openqa.selenium.build.InProject;
32+
import org.openqa.selenium.remote.RemoteWebDriver;
3233
import org.openqa.selenium.testing.JupiterTestBase;
3334
import org.openqa.selenium.testing.NoDriverBeforeTest;
3435
import org.openqa.selenium.testing.drivers.Browser;
@@ -49,8 +50,9 @@ public void canStartChromeWithCustomOptions() {
4950
localDriver = seleniumExtension.createNewDriver(options);
5051

5152
localDriver.get(pages.clickJacker);
53+
5254
Object userAgent =
53-
((ChromeDriver) localDriver).executeScript("return window.navigator.userAgent");
55+
((RemoteWebDriver) localDriver).executeScript("return window.navigator.userAgent");
5456
assertThat(userAgent).isEqualTo("foo;bar");
5557
}
5658

@@ -70,7 +72,8 @@ public void canSetAcceptInsecureCerts() {
7072
options.setAcceptInsecureCerts(true);
7173
localDriver = seleniumExtension.createNewDriver(options);
7274

73-
assertThat(((ChromeDriver) localDriver).getCapabilities().getCapability(ACCEPT_INSECURE_CERTS))
75+
assertThat(
76+
((RemoteWebDriver) localDriver).getCapabilities().getCapability(ACCEPT_INSECURE_CERTS))
7477
.isEqualTo(true);
7578
}
7679

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
package org.openqa.selenium.testing;
22

3-
import org.openqa.selenium.testing.drivers.Browser;
4-
53
import java.lang.annotation.ElementType;
64
import java.lang.annotation.Repeatable;
75
import java.lang.annotation.Retention;
86
import java.lang.annotation.RetentionPolicy;
97
import java.lang.annotation.Target;
8+
import org.openqa.selenium.testing.drivers.Browser;
109

1110
@Retention(RetentionPolicy.RUNTIME)
1211
@Target(ElementType.METHOD)
1312
@Repeatable(NotWorkingInRemoteBazelBuildsList.class)
1413
public @interface NotWorkingInRemoteBazelBuilds {
1514

1615
Browser value() default Browser.ALL;
17-
1816
}

java/test/org/openqa/selenium/testing/SeleniumExtension.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,19 @@ public void afterEach(ExtensionContext context) throws Exception {
149149
current));
150150
}
151151

152-
NotWorkingInRemoteBazelBuildsRule notWorkingInRemoteBuilds = new NotWorkingInRemoteBazelBuildsRule(context);
152+
NotWorkingInRemoteBazelBuildsRule notWorkingInRemoteBuilds =
153+
new NotWorkingInRemoteBazelBuildsRule(context);
153154
boolean isNotExpectedToWork = notWorkingInRemoteBuilds.check();
154155

155156
if (isNotExpectedToWork && !failedWithRemoteBuild) {
156157
Optional<Class<?>> testClass = context.getTestClass();
157158
Optional<Method> testMethod = context.getTestMethod();
158159
throw new Exception(
159-
String.format(
160-
"%s.%s is not yet expected to work on remote builds using %s, but it already works!",
161-
testClass.map(Class::getName).orElse(""),
162-
testMethod.map(Method::getName).orElse(""),
163-
Browser.detect()));
160+
String.format(
161+
"%s.%s is not yet expected to work on remote builds using %s, but it already works!",
162+
testClass.map(Class::getName).orElse(""),
163+
testMethod.map(Method::getName).orElse(""),
164+
Browser.detect()));
164165
}
165166
}
166167

@@ -220,7 +221,8 @@ public void handleTestExecutionException(ExtensionContext context, Throwable thr
220221
failedWithNotYetImplemented = true;
221222
}
222223

223-
NotWorkingInRemoteBazelBuildsRule notWorkingInRemoteBuilds = new NotWorkingInRemoteBazelBuildsRule(context);
224+
NotWorkingInRemoteBazelBuildsRule notWorkingInRemoteBuilds =
225+
new NotWorkingInRemoteBazelBuildsRule(context);
224226
if (notWorkingInRemoteBuilds.check()) {
225227
failedWithRemoteBuild = true;
226228
}
@@ -336,7 +338,6 @@ public boolean check() throws Exception {
336338
findRepeatableAnnotations(element, NotYetImplemented.class);
337339
return notImplemented(notYetImplementedList) || notImplemented(notYetImplemented.stream());
338340
}
339-
340341
}
341342

342343
private static class NotWorkingInRemoteBazelBuildsRule {
@@ -362,9 +363,9 @@ public boolean check() {
362363

363364
Optional<AnnotatedElement> element = context.getElement();
364365
Optional<NotWorkingInRemoteBazelBuilds> notWorkingList =
365-
findAnnotation(element, NotWorkingInRemoteBazelBuilds.class);
366+
findAnnotation(element, NotWorkingInRemoteBazelBuilds.class);
366367
List<NotWorkingInRemoteBazelBuilds> notWorking =
367-
findRepeatableAnnotations(element, NotWorkingInRemoteBazelBuilds.class);
368+
findRepeatableAnnotations(element, NotWorkingInRemoteBazelBuilds.class);
368369
return notWorkingYet(notWorkingList) || notWorkingYet(notWorking.stream());
369370
}
370371
}

0 commit comments

Comments
 (0)