Skip to content

Commit 37498f8

Browse files
committed
[java] toggle selenium manager output by exit value instead of content
1 parent 18fc634 commit 37498f8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

java/src/org/openqa/selenium/manager/SeleniumManager.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,12 @@ public static SeleniumManager getInstance() {
8989
*/
9090
private static String runCommand(String... command) {
9191
String output = "";
92+
int code = 0;
9293
try {
9394
Process process = new ProcessBuilder(command)
9495
.redirectErrorStream(true).start();
9596
process.waitFor();
97+
code = process.exitValue();
9698
output = CharStreams.toString(new InputStreamReader(
9799
process.getInputStream(), StandardCharsets.UTF_8));
98100
} catch (InterruptedException e) {
@@ -103,12 +105,12 @@ private static String runCommand(String... command) {
103105
LOG.warning(String.format("%s running command %s: %s",
104106
e.getClass().getSimpleName(), Arrays.toString(command), e.getMessage()));
105107
}
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);
109111
}
110112

111-
return output.trim();
113+
return output.replace(INFO, "").trim();
112114
}
113115

114116
/**
@@ -156,9 +158,8 @@ public String getDriverPath(String driverName) {
156158
String driverPath = null;
157159
File binaryFile = getBinary();
158160
if (binaryFile != null) {
159-
String output = runCommand(binaryFile.getAbsolutePath(),
161+
driverPath = runCommand(binaryFile.getAbsolutePath(),
160162
"--driver", driverName.replaceAll(EXE, ""));
161-
driverPath = output.replace(INFO, "");
162163
}
163164
return driverPath;
164165
}

0 commit comments

Comments
 (0)