@Nonnull private Object send(@Nonnull String cmd, @Nonnull Map<String, Object> params) throws IOException { Map<String, Object> exe = ImmutableMap.of("cmd", cmd, "params", params); Command xc = new Command(m_wd.getSessionId(), "sendCommandWithResult", exe); Response response = m_wd.getCommandExecutor().execute(xc); Object value = response.getValue(); if(response.getStatus() == null || response.getStatus().intValue() != 0) { //System.out.println("resp: " + response); throw new MyChromeDriverException("Command '" + cmd + "' failed: " + value); } if(null == value) throw new MyChromeDriverException("Null response value to command '" + cmd + "'"); //System.out.println("resp: " + value); return value; }
@Override public Response execute(Command command) throws IOException { Response response; if (DriverCommand.QUIT.equals(command.getName())) { response = grid.execute(command); } else { response = node.execute(command); } return response; }
@Override public Response execute(Command command) throws IOException, WebDriverException { if (DriverCommand.NEW_SESSION.equals(command.getName()) && service != null) { service.start(); } try { return super.execute(command); } catch (Throwable t) { Throwable rootCause = Throwables.getRootCause(t); if (rootCause instanceof ConnectException && rootCause.getMessage().contains("Connection refused") && service != null) { if (service.isRunning()) { throw new WebDriverException("The session is closed!", t); } if (!service.isRunning()) { throw new WebDriverException("The appium server has accidentally died!", t); } } Throwables.propagateIfPossible(t); throw new WebDriverException(t); } finally { if (DriverCommand.QUIT.equals(command.getName()) && service != null) { service.stop(); } } }
protected RestishHandler populate(RestishHandler handler, Command command) { for (Map.Entry<String, ?> entry : command.getParameters().entrySet()) { try { PropertyMunger.set(entry.getKey(), handler, entry.getValue()); } catch (Exception e) { throw new WebDriverException(e); } } return handler; }
public void beforeEvent(Command command) { if (command.getName().equalsIgnoreCase(DriverCommand.CLICK)) { System.out.println("Before click"); } }
public void afterEvent(Command command) { if (command.getName().equalsIgnoreCase(DriverCommand.CLICK)) { System.out.println("After click"); } }