41
41
import org .openqa .selenium .WebDriverException ;
42
42
import org .openqa .selenium .json .Json ;
43
43
import org .openqa .selenium .json .JsonException ;
44
+ import org .openqa .selenium .manager .SeleniumManagerOutput .Result ;
44
45
45
46
/**
46
47
* This implementation is still in beta, and may change.
@@ -100,7 +101,7 @@ public static SeleniumManager getInstance() {
100
101
* @param command the file and arguments to execute.
101
102
* @return the standard output of the execution.
102
103
*/
103
- private static String runCommand (String ... command ) {
104
+ private static Result runCommand (String ... command ) {
104
105
LOG .fine (String .format ("Executing Process: %s" , Arrays .toString (command )));
105
106
String output ;
106
107
int code ;
@@ -118,12 +119,12 @@ private static String runCommand(String... command) {
118
119
} catch (Exception e ) {
119
120
throw new WebDriverException ("Failed to run command: " + Arrays .toString (command ), e );
120
121
}
121
- SeleniumManagerJsonOutput jsonOutput = null ;
122
+ SeleniumManagerOutput jsonOutput = null ;
122
123
JsonException failedToParse = null ;
123
124
String dump = output ;
124
125
if (!output .isEmpty ()) {
125
126
try {
126
- jsonOutput = new Json ().toType (output , SeleniumManagerJsonOutput .class );
127
+ jsonOutput = new Json ().toType (output , SeleniumManagerOutput .class );
127
128
jsonOutput .logs .forEach (
128
129
logged -> {
129
130
if (logged .level .equalsIgnoreCase (WARN )) {
@@ -147,12 +148,12 @@ private static String runCommand(String... command) {
147
148
+ "\n "
148
149
+ dump ,
149
150
failedToParse );
150
- } else if (failedToParse != null ) {
151
+ } else if (failedToParse != null || jsonOutput == null ) {
151
152
throw new WebDriverException (
152
153
"Failed to parse json output, executed: " + Arrays .toString (command ) + "\n " + dump ,
153
154
failedToParse );
154
155
}
155
- return jsonOutput .result . message ;
156
+ return jsonOutput .result ;
156
157
}
157
158
158
159
/**
@@ -223,7 +224,7 @@ private String getBrowserBinary(Capabilities options) {
223
224
* @param options Browser Options instance.
224
225
* @return the location of the driver.
225
226
*/
226
- public String getDriverPath (Capabilities options , boolean offline ) {
227
+ public Result getDriverPath (Capabilities options , boolean offline ) {
227
228
File binaryFile = getBinary ();
228
229
if (binaryFile == null ) {
229
230
return null ;
@@ -265,9 +266,12 @@ public String getDriverPath(Capabilities options, boolean offline) {
265
266
}
266
267
}
267
268
268
- String path = runCommand (commandList .toArray (new String [0 ]));
269
- LOG .fine (String .format ("Using driver at location: %s" , path ));
270
- return path ;
269
+ Result result = runCommand (commandList .toArray (new String [0 ]));
270
+ LOG .fine (
271
+ String .format (
272
+ "Using driver at location: %s, browser at location %s" ,
273
+ result .getDriverPath (), result .getBrowserPath ()));
274
+ return result ;
271
275
}
272
276
273
277
private Level getLogLevel () {
0 commit comments