Skip to content

Commit 60c9f4a

Browse files
committed
[java] Format Selenium Manager wrapper class in Java
1 parent 771c22c commit 60c9f4a

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

java/src/org/openqa/selenium/manager/SeleniumManager.java

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
/**
4040
* This implementation is still in beta, and may change.
41-
*
41+
* <p>
4242
* The Selenium-Manager binaries are distributed in a JAR file (org.openqa.selenium:selenium-manager) for
4343
* the Java binding language. Since these binaries are compressed within these JAR, we need to serialize
4444
* the proper binary for the current platform (Windows, macOS, or Linux) as an executable file. To
@@ -59,9 +59,9 @@ public class SeleniumManager {
5959

6060
private File binary;
6161

62-
/**
63-
* Wrapper for the Selenium Manager binary.
64-
*/
62+
/**
63+
* Wrapper for the Selenium Manager binary.
64+
*/
6565
private SeleniumManager() {
6666
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
6767
if (binary != null && binary.exists()) {
@@ -82,11 +82,12 @@ public static SeleniumManager getInstance() {
8282
return manager;
8383
}
8484

85-
/**
86-
* Executes a process with the given arguments.
87-
* @param command the file and arguments to execute.
88-
* @return the standard output of the execution.
89-
*/
85+
/**
86+
* Executes a process with the given arguments.
87+
*
88+
* @param command the file and arguments to execute.
89+
* @return the standard output of the execution.
90+
*/
9091
private static String runCommand(String... command) {
9192
String output = "";
9293
int code = 0;
@@ -106,17 +107,18 @@ private static String runCommand(String... command) {
106107
e.getClass().getSimpleName(), Arrays.toString(command), e.getMessage()));
107108
}
108109
if (code > 0) {
109-
throw new WebDriverException("Unsuccessful command executed: " + Arrays.toString(command) +
110-
"\n" + output);
110+
throw new WebDriverException("Unsuccessful command executed: " + Arrays.toString(command) +
111+
"\n" + output);
111112
}
112113

113114
return output.replace(INFO, "").trim();
114115
}
115116

116-
/**
117-
* Determines the correct Selenium Manager binary to use.
118-
* @return the path to the Selenium Manager binary.
119-
*/
117+
/**
118+
* Determines the correct Selenium Manager binary to use.
119+
*
120+
* @return the path to the Selenium Manager binary.
121+
*/
120122
private synchronized File getBinary() {
121123
if (binary == null) {
122124
try {
@@ -145,11 +147,12 @@ private synchronized File getBinary() {
145147
return binary;
146148
}
147149

148-
/**
149-
* Determines the location of the correct driver.
150-
* @param driverName which driver the service needs.
151-
* @return the location of the driver.
152-
*/
150+
/**
151+
* Determines the location of the correct driver.
152+
*
153+
* @param driverName which driver the service needs.
154+
* @return the location of the driver.
155+
*/
153156
public String getDriverPath(String driverName) {
154157
if (!ImmutableList.of("geckodriver", "chromedriver", "msedgedriver", "IEDriverServer").contains(driverName)) {
155158
throw new WebDriverException("Unable to locate driver with name: " + driverName);
@@ -158,7 +161,7 @@ public String getDriverPath(String driverName) {
158161
String driverPath = null;
159162
File binaryFile = getBinary();
160163
if (binaryFile != null) {
161-
driverPath = runCommand(binaryFile.getAbsolutePath(),
164+
driverPath = runCommand(binaryFile.getAbsolutePath(),
162165
"--driver", driverName.replaceAll(EXE, ""));
163166
}
164167
return driverPath;

0 commit comments

Comments
 (0)