Java 类org.openqa.selenium.remote.ErrorCodes 实例源码

项目:grid-refactor-remote-server    文件:Status.java   
@Override
public Response handle() throws Exception {
  Response response = new Response();
  response.setStatus(ErrorCodes.SUCCESS);
  response.setState(ErrorCodes.SUCCESS_STRING);

  BuildInfo buildInfo = new BuildInfo();

  JsonObject info = new JsonObject();
  JsonObject build = new JsonObject();
  build.addProperty("version", buildInfo.getReleaseLabel());
  build.addProperty("revision", buildInfo.getBuildRevision());
  build.addProperty("time", buildInfo.getBuildTime());
  info.add("build", build);
  JsonObject os = new JsonObject();
  os.addProperty("name", System.getProperty("os.name"));
  os.addProperty("arch", System.getProperty("os.arch"));
  os.addProperty("version", System.getProperty("os.version"));
  info.add("os", os);
  JsonObject java = new JsonObject();
  java.addProperty("version", System.getProperty("java.version"));
  info.add("java", java);

  response.setValue(info);
  return response;
}
项目:devtools-driver    文件:AlertHandler.java   
@Override
public Response handle() throws Exception {
  // We don't have any way currently of dealing with alert dialogs with pure JS, so we respond to
  // every alert command with the "no alert present" error code.
  Response response = new Response();
  response.setSessionId(getSession().getSessionId());
  response.setStatus(ErrorCodes.NO_ALERT_PRESENT);
  response.setValue(new ErrorCodes().toState(ErrorCodes.NO_ALERT_PRESENT));
  return response;
}
项目:grid-refactor-remote-server    文件:ResultConfig.java   
public Throwable getRootExceptionCause(Throwable originalException) {
  Throwable toReturn = originalException;
  if (originalException instanceof UndeclaredThrowableException) {
    // An exception was thrown within an invocation handler. Not smart.
    // Extract the original exception
    toReturn = originalException.getCause().getCause();
  }

  // When catching an exception here, it is most likely wrapped by
  // several other exceptions. Peel the layers and use the original
  // exception as the one to return to the client. That is the most
  // likely to contain informative data about the error.
  // This is a safety measure to make sure this loop is never endless
  List<Throwable> chain = Lists.newArrayListWithExpectedSize(10);
  for (Throwable current = toReturn; current != null && chain.size() < 10; current =
      current.getCause()) {
    chain.add(current);
  }

  if (chain.isEmpty()) {
    return null;
  }

  // If the root cause came from another server implementing the wire protocol, there might
  // not have been enough information to fully reconstitute its error, in which case we'll
  // want to return the last 2 causes - with the outer error providing context to the
  // true root cause. These case are identified by the root cause not being mappable to a
  // standard WebDriver error code, but its wrapper is mappable.
  //
  // Of course, if we only have one item in our chain, go ahead and return.
  ErrorCodes ec = new ErrorCodes();
  Iterator<Throwable> reversedChain = Lists.reverse(chain).iterator();
  Throwable rootCause = reversedChain.next();
  if (!reversedChain.hasNext() || ec.isMappableError(rootCause)) {
    return rootCause;
  }
  Throwable nextCause = reversedChain.next();
  return ec.isMappableError(nextCause) ? nextCause : rootCause;
}
项目:grid-refactor-remote-server    文件:Responses.java   
/**
 * Creates a response object for a successful command execution.
 *
 * @param sessionId ID of the session that executed the command.
 * @param value the command result value.
 * @return the new response object.
 */
public static Response success(SessionId sessionId, Object value) {
  Response response = new Response();
  response.setSessionId(sessionId != null ? sessionId.toString() : null);
  response.setValue(value);
  response.setStatus(ErrorCodes.SUCCESS);
  response.setState(ErrorCodes.SUCCESS_STRING);
  return response;
}