Package org.openqa.selenium.remote

Examples of org.openqa.selenium.remote.Response


  }

  public static Response exctractResponse(HttpResponse resp) {
    String s = extractString(resp);
    try {
      Response response = new JsonToBeanConverter().convert(Response.class, s);
      return response;
    } catch (ClassCastException cce) {
      throw new WebDriverException("not a valid response " + s);
    }
View Full Code Here


    BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("GET", url);

    HttpHost h = new HttpHost(u.getHost(), u.getPort());
    HttpResponse response = client.execute(h, r);

    Response resp = Helper.exctractResponse(response);
    String value = (String) resp.getValue();
    return new JSONArray(value);
  }
View Full Code Here

        JSONObject jo = new JSONObject();
        jo.put("exitCode", exitCode);
        jo.put("stdout", toOutput(command.getStdOut()));
        jo.put("stderr", toOutput(command.getErr()));

        Response resp = new Response();
        resp.setSessionId(getSession().getSessionId());
        resp.setStatus(0);
        resp.setValue(jo);

        return resp;
    }
View Full Code Here

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

        // which has succeeded if we got here
        log.log(Level.WARNING,"set timout issue",e);
      }
    }

    Response resp = new Response();
    resp.setSessionId(getSession().getSessionId());
    resp.setStatus(0);
    resp.setValue(new JSONObject());
    return resp;
  }
View Full Code Here

  public Response handle() throws Exception {
    String script = getRequest().getPayload().getString("script");
    JSONArray args = getRequest().getPayload().getJSONArray("args");
    Object res = getWebDriver().executeScript(script, args);

    Response resp = new Response();
    resp.setSessionId(getSession().getSessionId());
    resp.setStatus(0);

    if (res instanceof RemoteObject) {
      RemoteObject ro = (RemoteObject) res;
      RemoteWebElement rwe = ro.getWebElement();
      JSONObject jo = new JSONObject().put("ELEMENT", rwe.getReference());
      resp.setValue(jo);
    } else if (res instanceof Integer) {
      resp.setValue(res);
    } else if (res instanceof Boolean) {
      resp.setValue(res);
    } else if (res instanceof Collection) {
      List<Object> rwes = new ArrayList<Object>();

      Collection<Object> all = (Collection<Object>) res;
      for (Object ro : all) {
        if (ro instanceof RemoteObject) {
          JSONObject
              jo =
              new JSONObject()
                  .put("ELEMENT", "" + ((RemoteObject) ro).getWebElement().getNodeId().getId());
          rwes.add(jo);
        } else {
          rwes.add(ro);
        }
      }

      resp.setValue(rwes);
    } else {
      resp.setValue(res);
    }

    return resp;
  }
View Full Code Here

    setJS(js);
  }

  @Override
  public Response handle() throws Exception {
    Response r = super.handle();
    return r;
  }
View Full Code Here

          "No element found for " + getRequest().getPayload() + " after waiting for " + implicitWait
          + " ms.");
    } else {
      JSONObject res = new JSONObject();
      res.put("ELEMENT", rwe.getReference());
      Response resp = new Response();
      resp.setSessionId(getSession().getSessionId());
      resp.setStatus(0);
      resp.setValue(res);
      return resp;
    }
  }
View Full Code Here

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

    Map<String, Object> m = conf.getAll();
    for (String key : m.keySet()) {
      res.put(key, m.get(key));
    }

    Response resp = new Response();
    resp.setSessionId(getSession().getSessionId());
    resp.setStatus(0);
    resp.setValue(res);
    return resp;
  }
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.