|
18 | 18 |
|
19 | 19 | import com.google.common.collect.ImmutableList; |
20 | 20 | import com.google.common.io.CharStreams; |
| 21 | + |
21 | 22 | import org.openqa.selenium.Beta; |
22 | 23 | import org.openqa.selenium.Capabilities; |
23 | 24 | import org.openqa.selenium.Platform; |
@@ -100,23 +101,26 @@ private static String runCommand(String... command) { |
100 | 101 | process.waitFor(); |
101 | 102 | code = process.exitValue(); |
102 | 103 | output = CharStreams.toString(new InputStreamReader( |
103 | | - process.getInputStream(), StandardCharsets.UTF_8)); |
| 104 | + process.getInputStream(), StandardCharsets.UTF_8)); |
104 | 105 | } catch (InterruptedException e) { |
105 | 106 | LOG.warning(String.format("Interrupted exception running command %s: %s", |
106 | | - Arrays.toString(command), e.getMessage())); |
| 107 | + Arrays.toString(command), e.getMessage())); |
107 | 108 | Thread.currentThread().interrupt(); |
108 | 109 | } catch (Exception e) { |
109 | 110 | LOG.warning(String.format("%s running command %s: %s", |
110 | | - e.getClass().getSimpleName(), Arrays.toString(command), e.getMessage())); |
| 111 | + e.getClass().getSimpleName(), Arrays.toString(command), |
| 112 | + e.getMessage())); |
111 | 113 | } |
| 114 | + SeleniumManagerJsonOutput jsonOutput = new Json() |
| 115 | + .toType(output, SeleniumManagerJsonOutput.class); |
112 | 116 | if (code > 0) { |
113 | | - throw new WebDriverException("Unsuccessful command executed: " + Arrays.toString(command) + |
114 | | - "\n" + output); |
| 117 | + throw new WebDriverException( |
| 118 | + "Unsuccessful command executed: " + Arrays.toString(command) + |
| 119 | + "\n" + jsonOutput.result.message); |
115 | 120 | } |
116 | | - SeleniumManagerJsonOutput jsonOutput = new Json().toType(output, |
117 | | - SeleniumManagerJsonOutput.class); |
118 | | - jsonOutput.logs.stream().filter(log -> log.level.equalsIgnoreCase(WARN)) |
119 | | - .forEach(log -> LOG.warning(log.message)); |
| 121 | + jsonOutput.logs.stream() |
| 122 | + .filter(log -> log.level.equalsIgnoreCase(WARN)) |
| 123 | + .forEach(log -> LOG.warning(log.message)); |
120 | 124 | return jsonOutput.result.message; |
121 | 125 | } |
122 | 126 |
|
@@ -172,15 +176,4 @@ public String getDriverPath(Capabilities options) { |
172 | 176 | } |
173 | 177 | return runCommand(commandList.toArray(new String[0])); |
174 | 178 | } |
175 | | - |
176 | | - public String getDriverPath(String driverName) { |
177 | | - File binaryFile = getBinary(); |
178 | | - if(binaryFile == null) { |
179 | | - return null; |
180 | | - } |
181 | | - ImmutableList<String> commandList = ImmutableList.of(binaryFile.getAbsolutePath(), |
182 | | - "--driver", driverName, |
183 | | - "--output", "json"); |
184 | | - return runCommand(commandList.toArray(new String[0])); |
185 | | - } |
186 | 179 | } |
0 commit comments