|
31 | 31 | import org.openqa.selenium.UnsupportedCommandException; |
32 | 32 | import org.openqa.selenium.WebDriverException; |
33 | 33 | import org.openqa.selenium.remote.CapabilityType; |
| 34 | +import org.openqa.selenium.remote.CommandInfo; |
34 | 35 | import org.openqa.selenium.remote.DriverCommand; |
35 | 36 | import org.openqa.selenium.remote.ErrorHandler; |
36 | 37 | import org.openqa.selenium.remote.ExecuteMethod; |
@@ -242,22 +243,23 @@ public Map<String, Object> getStatus() { |
242 | 243 | * @param methodName The name of custom appium command. |
243 | 244 | */ |
244 | 245 | public void addCommand(HttpMethod httpMethod, String url, String methodName) { |
| 246 | + CommandInfo commandInfo; |
245 | 247 | switch (httpMethod) { |
246 | 248 | case GET: |
247 | | - MobileCommand.commandRepository.put(methodName, MobileCommand.getC(url)); |
| 249 | + commandInfo = MobileCommand.getC(url); |
248 | 250 | break; |
249 | 251 | case POST: |
250 | | - MobileCommand.commandRepository.put(methodName, MobileCommand.postC(url)); |
| 252 | + commandInfo = MobileCommand.postC(url); |
251 | 253 | break; |
252 | 254 | case DELETE: |
253 | | - MobileCommand.commandRepository.put(methodName, MobileCommand.deleteC(url)); |
| 255 | + commandInfo = MobileCommand.deleteC(url); |
254 | 256 | break; |
255 | 257 | default: |
256 | 258 | throw new WebDriverException(String.format("Unsupported HTTP Method: %s. Only %s methods are supported", |
257 | 259 | httpMethod, |
258 | 260 | Arrays.toString(HttpMethod.values()))); |
259 | 261 | } |
260 | | - ((AppiumCommandExecutor) getCommandExecutor()).refreshAdditionalCommands(); |
| 262 | + ((AppiumCommandExecutor) getCommandExecutor()).defineCommand(methodName, commandInfo); |
261 | 263 | } |
262 | 264 |
|
263 | 265 | @Override |
|
0 commit comments