Package org.uiautomation.ios.wkrdp.model

Examples of org.uiautomation.ios.wkrdp.model.RemoteWebElement


    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);
View Full Code Here


  public Response handle() throws Exception {
    waitForPageToLoad();

    int implicitWait = (Integer) getConf("implicit_wait", 0);
    long deadline = System.currentTimeMillis() + implicitWait;
    RemoteWebElement rwe = null;
    do {
      try {
        rwe = findElement();
        break;
      } catch (InvalidSelectorException e) {
        // no recovery here.
        throw e;
      } catch (NoSuchElementException e) {
        //ignore and try again.
      } catch (RemoteExceptionException e2) {
        // looking on the root element, but document became invalid.
        // Something (alert during onload ) might have prevented the page
        // refresh.
        if (!getRequest().hasVariable(":reference")) {
          getWebDriver().getContext().newContext();
        }

      }
    } while (System.currentTimeMillis() < deadline);

    if (rwe == null) {
      throw new NoSuchElementException(
          "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

  private RemoteWebElement findElement() throws Exception {
    JSONObject payload = getRequest().getPayload();
    String type = payload.getString("using");
    String value = payload.getString("value");

    RemoteWebElement element = null;

    if (getRequest().hasVariable(":reference")) {
      String reference = getRequest().getVariableValue(":reference");
      element = getWebDriver().createElement(reference);
    } else {
      element = getWebDriver().getDocument();
    }
    RemoteWebElement rwe;
    if ("link text".equals(type)) {
      rwe = element.findElementByLinkText(value, false);
    } else if ("partial link text".equals(type)) {
      rwe = element.findElementByLinkText(value, true);
    } else if ("xpath".equals(type)) {
View Full Code Here

  }

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


  private RemoteWebElement retrieveDocument() throws Exception {
    JSONObject result = sendCommand(DOM.getDocument());
    JSONObject root = result.getJSONObject("root");
    RemoteWebElement rme = new RemoteWebElement(new NodeId(root.getInt("nodeId")), this);
    return rme;
  }
View Full Code Here

  }

  private String getCurrentUrlOnce() {

    try {
      RemoteWebElement document = getDocument();
      String f = "(function(arg) { var url=this.URL;return url;})";
      JSONObject cmd = new JSONObject();

      cmd.put("method", "Runtime.callFunctionOn");

      JSONArray args = new JSONArray();

      cmd.put("params", new JSONObject().put("objectId", document.getRemoteObject().getId())
          .put("functionDeclaration", f).put("arguments", args).put("returnByValue", true));

      JSONObject response = sendCommand(cmd);
      return cast(response);
    } catch (JSONException e) {
View Full Code Here

  public JSONObject getScriptResponse(String script) throws JSONException {
    return getScriptResponse(script, new JSONArray());
  }

  public JSONObject getScriptResponse(String script, JSONArray arguments) throws JSONException {
    RemoteWebElement document = getDocument();

    if (!context.isOnMainFrame()) {
      arguments.put(new JSONObject().put("objectId", document.getRemoteObject().getId()));
      arguments.put(new JSONObject().put("objectId", context.getWindow().getRemoteObject().getId()));

      String contextObject = "{'document': arguments[" + (arguments.length() - 2) + "], 'window': arguments[" + (arguments.length() - 1) + "]}";
      script = "with (" + contextObject + ") {" + script + "}";

    }

    JSONObject cmd = new JSONObject();
    cmd.put("method", "Runtime.callFunctionOn");
    cmd.put(
        "params",
        new JSONObject().put("objectId", document.getRemoteObject().getId())
            .put("functionDeclaration", "(function() { " + script + "})")
            .put("arguments", arguments)
            .put("returnByValue", false));
    JSONObject response = sendCommand(cmd);
    checkForJSErrors(response);
View Full Code Here

      if (arg instanceof JSONObject) {
        JSONObject jsonArg = (JSONObject) arg;
        if (jsonArg.optString("ELEMENT") != null) {
          // TODO use driver factory to check the  pageId
          NodeId n = new NodeId(Integer.parseInt(jsonArg.optString("ELEMENT").split("_")[1]));
          RemoteWebElement rwep = new RemoteWebElement(n, this);
          arguments.put(new JSONObject().put("objectId", rwep.getRemoteObject().getId()));
        }
      } else if (arg instanceof JSONArray) {
        JSONArray jsonArr = (JSONArray) arg;
        JSONObject array = getScriptResponse("return " + jsonArr.toString() + ";");
View Full Code Here

    return dim;

  }

  public RemoteWebElement findElementByCSSSelector(String cssSelector) {
    RemoteWebElement document = getDocument();
    return document.findElementByCSSSelector(cssSelector);
  }
View Full Code Here

    RemoteWebElement document = getDocument();
    return document.findElementByCSSSelector(cssSelector);
  }

  public List<RemoteWebElement> findElementsByCSSSelector(String cssSelector) {
    RemoteWebElement document = getDocument();
    return document.findElementsByCSSSelector(cssSelector);
  }
View Full Code Here

TOP

Related Classes of org.uiautomation.ios.wkrdp.model.RemoteWebElement

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.