|
21 | 21 | import static org.openqa.selenium.remote.DriverCommand.NEW_SESSION;
|
22 | 22 | import static org.openqa.selenium.remote.DriverCommand.QUIT;
|
23 | 23 |
|
| 24 | +import com.google.common.base.Preconditions; |
24 | 25 | import com.google.common.base.Throwables;
|
25 | 26 | import com.google.common.collect.ImmutableMap;
|
26 | 27 |
|
@@ -116,11 +117,23 @@ public HttpCommandExecutor(Map<String, CommandInfo> additionalCommands, URL addr
|
116 | 117 | host, remoteServer.getPort(), remoteServer.getProtocol());
|
117 | 118 |
|
118 | 119 | for (Map.Entry<String, CommandInfo> entry : additionalCommands.entrySet()) {
|
119 |
| - CommandInfo info = entry.getValue(); |
120 |
| - commandCodec.defineCommand(entry.getKey(), info.getMethod(), info.getUrl()); |
| 120 | + defineCommand(entry.getKey(), entry.getValue()); |
121 | 121 | }
|
122 | 122 | }
|
123 | 123 |
|
| 124 | + /** |
| 125 | + * It may be useful to extend the commands understood by this {@code HttpCommandExecutor} at run |
| 126 | + * time, and this can be achieved via this method. Note, this is protected, and expected usage is |
| 127 | + * for subclasses only to call this. |
| 128 | + * |
| 129 | + * @param commandName The name of the command to use. |
| 130 | + */ |
| 131 | + protected void defineCommand(String commandName, CommandInfo info) { |
| 132 | + Preconditions.checkNotNull(commandName); |
| 133 | + Preconditions.checkNotNull(info); |
| 134 | + commandCodec.defineCommand(commandName, info.getMethod(), info.getUrl()); |
| 135 | + } |
| 136 | + |
124 | 137 | public void setLocalLogs(LocalLogs logs) {
|
125 | 138 | this.logs = logs;
|
126 | 139 | }
|
|
0 commit comments