Package org.uiautomation.ios

Examples of org.uiautomation.ios.ServerSideSession


    waitForServerRun(server);
    HttpResponse response = client.execute(h, r);

    Assert.assertEquals(response.getStatusLine().getStatusCode(), 200);
    server.stopGracefully();
    ServerSideSession s = server.getDriver().createSession(IOSCapabilities.iphone("Safari"));
    Assert.assertNull(s);
    waitForServerToStop(server);

  }
View Full Code Here


    final IOSServerManager mgr = new IOSServerManager(config);
    addSafari(mgr, new StringBuilder());

    IOSCapabilities saf = IOSCapabilities.iphone("Safari");
    ServerSideSession session = mgr.createSession(saf);
    Assert.assertEquals(mgr.getSessions().size(), 1);
    Thread t = new Thread(new Runnable() {
      @Override
      public void run() {
View Full Code Here

    final IOSServerManager mgr = new IOSServerManager(config);
    addSafari(mgr, new StringBuilder());

    IOSCapabilities saf = IOSCapabilities.iphone("Safari");
    ServerSideSession session = mgr.createSession(saf);
    Assert.assertEquals(mgr.getSessions().size(), 1);
    Thread t = new Thread(new Runnable() {
      @Override
      public void run() {
        try {
          mgr.stopGracefully();
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
    });

    t.start();

    mgr.waitForState(IOSServerManager.State.stopping);
    ServerSideSession session2 = mgr.createSession(saf);
    Assert.assertNull(session2);

    mgr.registerSessionHasStop(session);
    Assert.assertEquals(mgr.getSessions().size(), 0);
View Full Code Here

    return noConfigDefined();
  }

  @Override
  public Response handle() throws Exception {
    ServerSideSession session = getSession();
    Set<String> types = session.getLogManager().getTypes();
    return createResponse(types);
  }
View Full Code Here

  }

  @Override
  public Response handle() throws Exception {

    ServerSideSession session = null;
    try {
      JSONObject payload = getRequest().getPayload();
      IOSCapabilities cap = new IOSCapabilities(payload.getJSONObject("desiredCapabilities"));

      long timeOut = TIMEOUT_SEC;
      for (int i = 0; i < MAX_RETRIES; i++) {
        session = safeStart(timeOut, cap);
        timeOut = (i + 2) * TIMEOUT_SEC;

        if (session != null) {
          break;
        }
      }

      if (session == null) {
        throw new SessionNotCreatedException(
            "failed starting after " + MAX_RETRIES + " retries.Final wait was " + timeOut);
      }

      Response resp = new Response();
      resp.setSessionId(session.getSessionId());
      resp.setStatus(0);
      resp.setValue("");
      return resp;
    } catch (Exception e) {
      if (session != null) {
        session.stop();
      }
      if (e instanceof WebDriverException) {
        throw e;
      } else {
        throw new SessionNotCreatedException(e.getMessage(), e);
View Full Code Here

    }
  }

  private ServerSideSession safeStart(long timeOut, IOSCapabilities cap)
      throws InstrumentsFailedToStartException {
    ServerSideSession session = null;
    try {
      // init session
      session = getServer().createSession(cap);
      if (session == null) {
        throw new ServerIsShutingDownException(
            "The server is currently shutting down and doesn't accept new tests.");
      }

      // start session
      session.start(timeOut);
      return session;
    } catch (SessionNotInitializedException e) {
      log.info("The server cannot run " + cap + " at the moment." + e.getMessage());
      throw new SessionNotCreatedException("The server cannot run " + cap + " at the moment." + e.getMessage());
    } catch (InstrumentsFailedToStartException|RecoverableCrashException e) {
      log.warning("Instruments failed to start in the allocated time ( " + timeOut + "sec):" + e
          .getMessage());
      if (session != null) {
        session.stop();
      }
    } catch (Exception e) {
      log.warning("Error starting the session." + e.getMessage());
      if (session != null) {
        session.stop();
      }
      throw e;
    } finally {
      if (session != null && session.getStopCause() != null) {
        log.warning("app has crashed at startup :" + session.getStopCause());
      }
    }
    return null;
  }
View Full Code Here

        log.fine("content : " + r);

        if (r.isFirstResponse()) {
          log.fine("got first response");
          Response resp = r.getResponse();
          ServerSideSession session = getDriver().getSession(resp.getSessionId());
          session.setCapabilityCachedResponse(resp);
          //GetCapabilitiesNHandler.setCachedResponse(resp);
          RemoteIOSNativeDriver
              nativeDriver =
              getDriver().getSession(resp.getSessionId()).getDualDriver().getNativeDriver();
          nativeDriver.communication().registerUIAScript();
View Full Code Here

    o.put("value", r.getValue().toString());
    return o.toString();
  }

  private Response getResponse(WebDriverLikeRequest request) throws JSONException {
    ServerSideSession session = null;
    if (request.hasSession()) {
      try {
        session = getDriver().getSession(request.getSession());
        session.updateLastCommandTime();
      } catch (WebDriverException e) {
        Response response = new Response();
        response.setStatus(13);
        response.setValue(serializeException(e));
        return response;
View Full Code Here

      Map<String, Object> value = (Map<String, Object>) response.getValue();
      Map<String, Object> tree = (Map<String, Object>) value.get("tree");

      Map<String, Object> webView = (Map<String, Object>) getWebView(tree);
      if (webView != null) {
        ServerSideSession session = getDriver().getSession(getRequest().getSession());
        RemoteIOSWebDriver inspector = getWebDriver();
        try {
          String rawHTML = inspector.getPageSource();
          webView.put("source", rawHTML);
        } catch (Exception e) {
View Full Code Here

    return noConfigDefined();
  }

  @Override
  public Response handle() throws Exception {
    ServerSideSession session = getSession();
    JSONObject payload = getRequest().getPayload();
    String type = payload.getString("type");
    List<LogEntry> entries = session.getLogManager().getLog(type);
    return createResponse(entries);
  }
View Full Code Here

TOP

Related Classes of org.uiautomation.ios.ServerSideSession

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.