@@ -96,7 +96,7 @@ public static SeleniumManager getInstance() {
96
96
* @return the standard output of the execution.
97
97
*/
98
98
private static String runCommand (String ... command ) {
99
- LOG .fine (String .format ("Executing Process: %s" , command ));
99
+ LOG .fine (String .format ("Executing Process: %s" , Arrays . toString ( command ) ));
100
100
String output = "" ;
101
101
int code = 0 ;
102
102
try {
@@ -122,8 +122,7 @@ private static String runCommand(String... command) {
122
122
"Unsuccessful command executed: " + Arrays .toString (command ) +
123
123
"\n " + jsonOutput .result .message );
124
124
}
125
- jsonOutput .logs .stream ()
126
- .forEach (logged -> {
125
+ jsonOutput .logs .forEach (logged -> {
127
126
if (logged .level .equalsIgnoreCase (WARN )) {
128
127
LOG .warning (logged .message );
129
128
}
@@ -141,28 +140,28 @@ private static String runCommand(String... command) {
141
140
*/
142
141
private synchronized File getBinary () {
143
142
if (binary == null ) {
144
- try {
145
- Platform current = Platform .getCurrent ();
146
- String folder = "linux" ;
147
- String extension = "" ;
148
- if (current .is (WINDOWS )) {
149
- extension = EXE ;
150
- folder = "windows" ;
151
- } else if (current .is (MAC )) {
152
- folder = "macos" ;
153
- }
154
- String binaryPath = String .format ("%s/%s%s" , folder , SELENIUM_MANAGER , extension );
155
- try (InputStream inputStream = this .getClass ().getResourceAsStream (binaryPath )) {
156
- Path tmpPath = Files .createTempDirectory (SELENIUM_MANAGER + System .nanoTime ());
157
- File tmpFolder = tmpPath .toFile ();
158
- tmpFolder .deleteOnExit ();
159
- binary = new File (tmpFolder , SELENIUM_MANAGER + extension );
160
- Files .copy (inputStream , binary .toPath (), REPLACE_EXISTING );
161
- }
162
- binary .setExecutable (true );
163
- } catch (Exception e ) {
164
- throw new WebDriverException ("Unable to obtain Selenium Manager" , e );
143
+ try {
144
+ Platform current = Platform .getCurrent ();
145
+ String folder = "linux" ;
146
+ String extension = "" ;
147
+ if (current .is (WINDOWS )) {
148
+ extension = EXE ;
149
+ folder = "windows" ;
150
+ } else if (current .is (MAC )) {
151
+ folder = "macos" ;
152
+ }
153
+ String binaryPath = String .format ("%s/%s%s" , folder , SELENIUM_MANAGER , extension );
154
+ try (InputStream inputStream = this .getClass ().getResourceAsStream (binaryPath )) {
155
+ Path tmpPath = Files .createTempDirectory (SELENIUM_MANAGER + System .nanoTime ());
156
+ File tmpFolder = tmpPath .toFile ();
157
+ tmpFolder .deleteOnExit ();
158
+ binary = new File (tmpFolder , SELENIUM_MANAGER + extension );
159
+ Files .copy (inputStream , binary .toPath (), REPLACE_EXISTING );
165
160
}
161
+ binary .setExecutable (true );
162
+ } catch (Exception e ) {
163
+ throw new WebDriverException ("Unable to obtain Selenium Manager" , e );
164
+ }
166
165
}
167
166
return binary ;
168
167
}
@@ -196,34 +195,46 @@ private String getBrowserBinary(Capabilities options) {
196
195
* @return the location of the driver.
197
196
*/
198
197
public String getDriverPath (Capabilities options ) {
199
- LOG .info ("applicable driver not found; attempting to install with Selenium Manager (Beta)" );
198
+ LOG .info ("Applicable driver not found; attempting to install with Selenium Manager (Beta)" );
200
199
File binaryFile = getBinary ();
201
- if (binaryFile == null ) {
202
- return null ;
203
- }
204
- List <String > commandList = new ArrayList <>();
205
- commandList .add (binaryFile .getAbsolutePath ());
206
- commandList .add ("--browser" );
207
- commandList .add (options .getBrowserName ());
208
- commandList .add ("--output" );
209
- commandList .add ("json" );
210
- if (!options .getBrowserVersion ().isEmpty ()) {
211
- commandList .add ("--browser-version" );
212
- commandList .add (options .getBrowserVersion ());
213
- }
214
-
215
- String browserBinary = getBrowserBinary (options );
216
- if (browserBinary != null && !browserBinary .isEmpty ()) {
217
- commandList .add ("--browser-path" );
218
- commandList .add (browserBinary );
219
- }
220
-
221
- if (LOG .getLevel ().intValue () > Level .FINE .intValue ()) {
222
- commandList .add ("--verbose" );
223
- }
200
+ if (binaryFile == null ) {
201
+ return null ;
202
+ }
203
+ List <String > commandList = new ArrayList <>();
204
+ commandList .add (binaryFile .getAbsolutePath ());
205
+ commandList .add ("--browser" );
206
+ commandList .add (options .getBrowserName ());
207
+ commandList .add ("--output" );
208
+ commandList .add ("json" );
209
+
210
+ if (!options .getBrowserVersion ().isEmpty ()) {
211
+ commandList .add ("--browser-version" );
212
+ commandList .add (options .getBrowserVersion ());
213
+ }
214
+
215
+ String browserBinary = getBrowserBinary (options );
216
+ if (browserBinary != null && !browserBinary .isEmpty ()) {
217
+ commandList .add ("--browser-path" );
218
+ commandList .add (browserBinary );
219
+ }
220
+
221
+ if (getLogLevel ().intValue () <= Level .FINE .intValue ()) {
222
+ commandList .add ("--debug" );
223
+ }
224
224
225
225
String path = runCommand (commandList .toArray (new String [0 ]));
226
226
LOG .fine (String .format ("Using driver at location: %s" , path ));
227
227
return path ;
228
228
}
229
+
230
+ private Level getLogLevel () {
231
+ Level level = LOG .getLevel ();
232
+ if (level == null && LOG .getParent () != null ) {
233
+ level = LOG .getParent ().getLevel ();
234
+ }
235
+ if (level == null ) {
236
+ return Level .INFO ;
237
+ }
238
+ return level ;
239
+ }
229
240
}
0 commit comments