Package org.openqa.selenium.remote

Examples of org.openqa.selenium.remote.Response


  @Override
  public Response handle() throws Exception {

    List<Cookie> cookies = getWebDriver().getCookies();
    Response res = new Response();
    res.setSessionId(getSession().getSessionId());
    res.setStatus(0);
    res.setValue(cookies);
    return res;
  }
View Full Code Here


      fakeTypeURL(url);
    }
    /*if (newPageWillBeLoaded) {
      getSession().getRemoteWebDriver().waitForPageToLoad();
    } */
    Response res = new Response();
    res.setSessionId(getSession().getSessionId());
    res.setStatus(0);
    res.setValue(new JSONObject());
    return res;
  }
View Full Code Here

  public Response handle() throws Exception {
    String script = getRequest().getPayload().getString("script");
    JSONArray args = getRequest().getPayload().getJSONArray("args");
    Object res = getWebDriver().executeAsyncScript(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

      service.startSafari();
    } catch (IOException | SDKException e) {
      throw new WebDriverException("Cannot start safari : " + e.getMessage(), e);
    }

    Response r = session.getCachedCapabilityResponse();
    if (r == null) {
      r = new Response();
      r.setSessionId(session.getSessionId());
      Map<String, Object> o = new HashMap<>();
      List<String> ls = session.getApplication().getSupportedLanguagesCodes();

      o.put("supportedLocales", ls);
      o.put("takesScreenshot", true);
      o.put(IOSCapabilities.CONFIGURABLE, true);
      o.put(IOSCapabilities.ELEMENT_TREE, true);
      o.put(IOSCapabilities.IOS_SEARCH_CONTEXT, true);
      o.put(IOSCapabilities.IOS_TOUCH_SCREEN, true);

      o.put("rotatable", true);
      o.put("locationContextEnabled", true);

      o.put("browserName", session.getCapabilities().getBundleName());
      o.put("browserVersion", session.getApplication().getCapabilities().getBundleVersion());

      o.put("platform", "IOS");
      o.put("platformName", "IOS");
      o.put("platformVersion", session.getCapabilities().getSDKVersion());

      o.put("javascriptEnabled", true);
      o.put("cssSelectors", true);
      o.put("takesElementScreenshot", false);

      o.put(IOSCapabilities.SIMULATOR, false);
      o.put(IOSCapabilities.DEVICE, session.getCapabilities().getDevice());
      o.put(IOSCapabilities.VARIATION, session.getCapabilities().getDeviceVariation());
      r.setValue(o);
      session.setCapabilityCachedResponse(r);
    }
  }
View Full Code Here

  public Response handle() throws Exception {
    String attributeName = getRequest().getVariableValue(":name");
    String ref = getRequest().getVariableValue(":reference");
    RemoteWebElement element = getWebDriver().createElement(ref);
    Object value = element.getAttribute(attributeName);
    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 {

    Response res = new Response();
    res.setSessionId(getSession().getSessionId());
    res.setStatus(0);
    res.setValue(getWebDriver().getSize());
    return res;
  }
View Full Code Here

  protected final void handleLastCommand(UIAScriptRequest request) {
    // Stop is a fire and forget response. It will kill the instruments script,
    // so the script cannot
    // send a response.
    if ("stop".equals(request.getScript())) {
      Response response = new Response();
      response.setSessionId(getSessionId());
      response.setStatus(0);
      response.setValue(STOP_RESPONSE);
      BeanToJsonConverter converter = new BeanToJsonConverter();
      String json = converter.convert(response);
      UIAScriptResponse r = new UIAScriptResponse(json);
      setNextResponse(r);
    }
View Full Code Here

        res = responseQueue.poll(1000, TimeUnit.MILLISECONDS);
      } catch (InterruptedException ignore) {
      }
      // the executor is now stopped. Not need to wait any further
      if (!isReady()) {
        Response r = new Response();
        r.setStatus(13);
        r.setSessionId(getSessionId());
        if (session.getStopCause() != null) {
          r.setValue(session.getStopCause().name());
        } else {
          r.setValue(UNKNOWN_REASON);
        }
        UIAScriptResponse response = new UIAScriptResponse(new BeanToJsonConverter().convert(r));
        return response;
      }
View Full Code Here

    getWebDriver().getContext().newContext();
    getWebDriver().refresh();
    // needed to add this waitForLoadEvent() as waitForPageToLoad() is empty currently
    getWebDriver().getContext().waitForLoadEvent();
    getWebDriver().waitForPageToLoad();
    Response res = new Response();
    res.setSessionId(getSession().getSessionId());
    res.setStatus(0);
    res.setValue(new JSONObject());
    return res;
  }
View Full Code Here

      ((RemoteWebNativeBackedElement) element).setValueNative(value);
    } else {
      element.setValueAtoms(value);
    }

    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.