/** * Get an array of elements from the {@link AndroidElementsHash} and return the element's ids * using JSON. * * @param sel A UiSelector that targets the element to fetch. * @param contextId The Id of the element used for the context. * @return JSONObject * @throws JSONException * @throws UiObjectNotFoundException * @throws ElementNotInHashException */ private JSONArray fetchElements(final UiSelector sel, final String contextId) throws JSONException, ElementNotInHashException, UiObjectNotFoundException { final JSONArray resArray = new JSONArray(); final ArrayList<AndroidElement> els = elements.getElements(sel, contextId); for (final AndroidElement el : els) { resArray.put(new JSONObject().put("ELEMENT", el.getId())); } return resArray; }
/** * Get the element from the {@link AndroidElementsHash} and return the element id using JSON. * * @param sel A UiSelector that targets the element to fetch. * @param contextId The Id of the element used for the context. * @return JSONObject * @throws JSONException * @throws ElementNotFoundException * @throws ElementNotInHashException */ private JSONObject fetchElement(final UiSelector sel, final String contextId) throws JSONException, ElementNotFoundException, ElementNotInHashException { final JSONObject res = new JSONObject(); final AndroidElement el = elements.getElement(sel, contextId); return res.put("ELEMENT", el.getId()); }