@@ -89,10 +89,12 @@ public static SeleniumManager getInstance() {
89
89
*/
90
90
private static String runCommand (String ... command ) {
91
91
String output = "" ;
92
+ int code = 0 ;
92
93
try {
93
94
Process process = new ProcessBuilder (command )
94
95
.redirectErrorStream (true ).start ();
95
96
process .waitFor ();
97
+ code = process .exitValue ();
96
98
output = CharStreams .toString (new InputStreamReader (
97
99
process .getInputStream (), StandardCharsets .UTF_8 ));
98
100
} catch (InterruptedException e ) {
@@ -103,12 +105,12 @@ private static String runCommand(String... command) {
103
105
LOG .warning (String .format ("%s running command %s: %s" ,
104
106
e .getClass ().getSimpleName (), Arrays .toString (command ), e .getMessage ()));
105
107
}
106
- if (! output . startsWith ( INFO ) ) {
107
- throw new WebDriverException ("Error running selenium-manager : " + Arrays .toString (command ) +
108
- ": " + output );
108
+ if (code > 0 ) {
109
+ throw new WebDriverException ("Unsuccessful command executed : " + Arrays .toString (command ) +
110
+ " \n " + output );
109
111
}
110
112
111
- return output .trim ();
113
+ return output .replace ( INFO , "" ). trim ();
112
114
}
113
115
114
116
/**
@@ -156,9 +158,8 @@ public String getDriverPath(String driverName) {
156
158
String driverPath = null ;
157
159
File binaryFile = getBinary ();
158
160
if (binaryFile != null ) {
159
- String output = runCommand (binaryFile .getAbsolutePath (),
161
+ driverPath = runCommand (binaryFile .getAbsolutePath (),
160
162
"--driver" , driverName .replaceAll (EXE , "" ));
161
- driverPath = output .replace (INFO , "" );
162
163
}
163
164
return driverPath ;
164
165
}
0 commit comments