@@ -96,7 +96,7 @@ public static SeleniumManager getInstance() {
9696 * @return the standard output of the execution.
9797 */
9898 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 ) ));
100100 String output = "" ;
101101 int code = 0 ;
102102 try {
@@ -122,8 +122,7 @@ private static String runCommand(String... command) {
122122 "Unsuccessful command executed: " + Arrays .toString (command ) +
123123 "\n " + jsonOutput .result .message );
124124 }
125- jsonOutput .logs .stream ()
126- .forEach (logged -> {
125+ jsonOutput .logs .forEach (logged -> {
127126 if (logged .level .equalsIgnoreCase (WARN )) {
128127 LOG .warning (logged .message );
129128 }
@@ -141,28 +140,28 @@ private static String runCommand(String... command) {
141140 */
142141 private synchronized File getBinary () {
143142 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 );
165160 }
161+ binary .setExecutable (true );
162+ } catch (Exception e ) {
163+ throw new WebDriverException ("Unable to obtain Selenium Manager" , e );
164+ }
166165 }
167166 return binary ;
168167 }
@@ -196,34 +195,46 @@ private String getBrowserBinary(Capabilities options) {
196195 * @return the location of the driver.
197196 */
198197 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)" );
200199 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+ }
224224
225225 String path = runCommand (commandList .toArray (new String [0 ]));
226226 LOG .fine (String .format ("Using driver at location: %s" , path ));
227227 return path ;
228228 }
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+ }
229240}
0 commit comments