38
38
39
39
/**
40
40
* This implementation is still in beta, and may change.
41
- *
41
+ * <p>
42
42
* The Selenium-Manager binaries are distributed in a JAR file (org.openqa.selenium:selenium-manager) for
43
43
* the Java binding language. Since these binaries are compressed within these JAR, we need to serialize
44
44
* the proper binary for the current platform (Windows, macOS, or Linux) as an executable file. To
@@ -59,9 +59,9 @@ public class SeleniumManager {
59
59
60
60
private File binary ;
61
61
62
- /**
63
- * Wrapper for the Selenium Manager binary.
64
- */
62
+ /**
63
+ * Wrapper for the Selenium Manager binary.
64
+ */
65
65
private SeleniumManager () {
66
66
Runtime .getRuntime ().addShutdownHook (new Thread (() -> {
67
67
if (binary != null && binary .exists ()) {
@@ -82,11 +82,12 @@ public static SeleniumManager getInstance() {
82
82
return manager ;
83
83
}
84
84
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
+ */
90
91
private static String runCommand (String ... command ) {
91
92
String output = "" ;
92
93
int code = 0 ;
@@ -106,17 +107,18 @@ private static String runCommand(String... command) {
106
107
e .getClass ().getSimpleName (), Arrays .toString (command ), e .getMessage ()));
107
108
}
108
109
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 );
111
112
}
112
113
113
114
return output .replace (INFO , "" ).trim ();
114
115
}
115
116
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
+ */
120
122
private synchronized File getBinary () {
121
123
if (binary == null ) {
122
124
try {
@@ -145,11 +147,12 @@ private synchronized File getBinary() {
145
147
return binary ;
146
148
}
147
149
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
+ */
153
156
public String getDriverPath (String driverName ) {
154
157
if (!ImmutableList .of ("geckodriver" , "chromedriver" , "msedgedriver" , "IEDriverServer" ).contains (driverName )) {
155
158
throw new WebDriverException ("Unable to locate driver with name: " + driverName );
@@ -158,7 +161,7 @@ public String getDriverPath(String driverName) {
158
161
String driverPath = null ;
159
162
File binaryFile = getBinary ();
160
163
if (binaryFile != null ) {
161
- driverPath = runCommand (binaryFile .getAbsolutePath (),
164
+ driverPath = runCommand (binaryFile .getAbsolutePath (),
162
165
"--driver" , driverName .replaceAll (EXE , "" ));
163
166
}
164
167
return driverPath ;
0 commit comments