4141import org .openqa .selenium .WebDriverException ;
4242import org .openqa .selenium .json .Json ;
4343import org .openqa .selenium .json .JsonException ;
44+ import org .openqa .selenium .manager .SeleniumManagerOutput .Result ;
4445
4546/**
4647 * This implementation is still in beta, and may change.
@@ -100,7 +101,7 @@ public static SeleniumManager getInstance() {
100101 * @param command the file and arguments to execute.
101102 * @return the standard output of the execution.
102103 */
103- private static String runCommand (String ... command ) {
104+ private static Result runCommand (String ... command ) {
104105 LOG .fine (String .format ("Executing Process: %s" , Arrays .toString (command )));
105106 String output ;
106107 int code ;
@@ -118,12 +119,12 @@ private static String runCommand(String... command) {
118119 } catch (Exception e ) {
119120 throw new WebDriverException ("Failed to run command: " + Arrays .toString (command ), e );
120121 }
121- SeleniumManagerJsonOutput jsonOutput = null ;
122+ SeleniumManagerOutput jsonOutput = null ;
122123 JsonException failedToParse = null ;
123124 String dump = output ;
124125 if (!output .isEmpty ()) {
125126 try {
126- jsonOutput = new Json ().toType (output , SeleniumManagerJsonOutput .class );
127+ jsonOutput = new Json ().toType (output , SeleniumManagerOutput .class );
127128 jsonOutput .logs .forEach (
128129 logged -> {
129130 if (logged .level .equalsIgnoreCase (WARN )) {
@@ -147,12 +148,12 @@ private static String runCommand(String... command) {
147148 + "\n "
148149 + dump ,
149150 failedToParse );
150- } else if (failedToParse != null ) {
151+ } else if (failedToParse != null || jsonOutput == null ) {
151152 throw new WebDriverException (
152153 "Failed to parse json output, executed: " + Arrays .toString (command ) + "\n " + dump ,
153154 failedToParse );
154155 }
155- return jsonOutput .result . message ;
156+ return jsonOutput .result ;
156157 }
157158
158159 /**
@@ -223,7 +224,7 @@ private String getBrowserBinary(Capabilities options) {
223224 * @param options Browser Options instance.
224225 * @return the location of the driver.
225226 */
226- public String getDriverPath (Capabilities options , boolean offline ) {
227+ public Result getDriverPath (Capabilities options , boolean offline ) {
227228 File binaryFile = getBinary ();
228229 if (binaryFile == null ) {
229230 return null ;
@@ -265,9 +266,12 @@ public String getDriverPath(Capabilities options, boolean offline) {
265266 }
266267 }
267268
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 ;
271275 }
272276
273277 private Level getLogLevel () {
0 commit comments