Package org.openqa.selenium.remote

Examples of org.openqa.selenium.remote.Response


  @Override
  public Response handle() throws Exception {
    int id = Integer.parseInt(getRequest().getVariableValue(":reference"));
    int other = Integer.parseInt(getRequest().getVariableValue(":other"));
    boolean equal = equal(id, other);
    Response res = new Response();
    res.setSessionId(getSession().getSessionId());
    res.setStatus(0);
    res.setValue(equal);
    return res;
  }
View Full Code Here


    response.setContentType("application/json;charset=UTF-8");
    response.setCharacterEncoding("UTF-8");

    try {
      response.setStatus(200);
      Response resp = getResponse(req);

      // TODO implement the json protocol properly.
      if (req.getGenericCommand() == WebDriverLikeCommand.NEW_SESSION && resp.getStatus() == 0) {
        response.setStatus(301);
        String session = resp.getSessionId();

        if (session == null || session.isEmpty()) {
          response.setStatus(500);
        }
View Full Code Here

    if (request.hasSession()) {
      try {
        session = getDriver().getSession(request.getSession());
        session.updateLastCommandTime();
      } catch (WebDriverException e) {
        Response response = new Response();
        response.setStatus(13);
        response.setValue(serializeException(e));
        return response;
      }
    }

    // otherwise,forward to the driver to get the response.
    Level level = Level.FINE;
    long startTime = System.currentTimeMillis();
    WebDriverLikeCommand wdlc = null;
    try {
      wdlc = request.getGenericCommand();
      Handler h = CommandMapping.get(wdlc).createHandler(getDriver(), request);
      return h.handleAndRunDecorators();
    } catch (Exception we) {
      Response response = new Response();

      response.setStatus(errorCodes.toStatusCode(we));

      if (wdlc != null && wdlc.isSessionLess()) {
        response.setSessionId("");
      } else {
        response.setSessionId(request.getSession());
      }

      try {
        JSONObject o = serializeException(we);
        response.setValue(o);
      } catch (JSONException e) {
        level = Level.SEVERE;
        log.warning(e.toString());
      }
      return response;
View Full Code Here

    }
  }

  @Override
  public String getScreenshot() {
    Response r = executeScreenshotCommand();
    return extractScreenshot(r);
  }
View Full Code Here

  @Override
  public Response handle() throws Exception {
    String ref = getRequest().getVariableValue(":reference");
    RemoteWebElement element = getWebDriver().createElement(ref);
    boolean isSelected = element.isSelected();
    Response res = new Response();
    res.setSessionId(getSession().getSessionId());
    res.setStatus(0);
    res.setValue(isSelected);
    return res;
  }
View Full Code Here

  public Response handle() throws Exception {
    if (js == null) {
      throw new RuntimeException("need to specify the JS to run");
    }
    UIAScriptRequest r = new UIAScriptRequest(js);
    Response response = getNativeDriver().getInstruments().executeCommand(r);
    return response;

  }
View Full Code Here

  @Override
  public Response handle() throws Exception {
    String ref = getRequest().getVariableValue(":reference");
    RemoteWebElement element = getWebDriver().createElement(ref);
    String value = element.getTagName();
    Response res = new Response();
    res.setSessionId(getSession().getSessionId());
    res.setStatus(0);
    res.setValue(value);
    return res;
  }
View Full Code Here

  @Override
  public Response handle() throws Exception {
    String ref = getRequest().getVariableValue(":reference");
    RemoteWebElement element = getWebDriver().createElement(ref);
    boolean isEnabled = element.isEnabled();
    Response res = new Response();
    res.setSessionId(getSession().getSessionId());
    res.setStatus(0);
    res.setValue(isEnabled);
    return res;
  }
View Full Code Here

  }

  @Override
  public Response handle() throws Exception {
    String url = getWebDriver().getCurrentUrl();
    Response res = new Response();
    res.setSessionId(getSession().getSessionId());
    res.setStatus(0);
    res.setValue(url);
    return res;
  }
View Full Code Here

      getWebDriver().forward();
    }

    // no page loading event for forward ?
    // getSession().getRemoteWebDriver().waitForPageToLoad();
    Response res = new Response();
    res.setSessionId(getSession().getSessionId());
    res.setStatus(0);
    res.setValue(new JSONObject());
    return res;
  }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.remote.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.