コード例 #1
0
 @Override
 @SuppressWarnings("unchecked")
 public UIAElementArray<UIAElement> findElements(Criteria c) {
   try {
     JSONObject payload = new JSONObject();
     payload.put("depth", -1);
     payload.put("criteria", c.getJSONRepresentation());
     return (UIAElementArray<UIAElement>) getRemoteObject(WebDriverLikeCommand.ELEMENTS, payload);
   } catch (JSONException e) {
     throw new IOSAutomationException(e);
   }
 }
コード例 #2
0
  @Override
  public UIAElement findElement(Criteria c) throws NoSuchElementException {
    long deadline = System.currentTimeMillis() + timeout;

    while (System.currentTimeMillis() < deadline) {
      try {
        JSONObject payload = new JSONObject();
        payload.put("depth", -1);
        payload.put("criteria", c.getJSONRepresentation());
        return (UIAElement) getRemoteObject(WebDriverLikeCommand.ELEMENT, payload);
      } catch (JSONException e) {
        throw new IOSAutomationException(e);
      } catch (NoSuchElementException ignore) {
      }
    }
    try {
      throw new NoSuchElementException(
          "timeout after " + timeout + " trying to find " + c.getJSONRepresentation().toString());
    } catch (JSONException e) {
      throw new IOSAutomationException(e);
    }
  }