当前位置: 首页>>代码示例>>Java>>正文


Java DeleteSession类代码示例

本文整理汇总了Java中org.openqa.selenium.remote.server.handler.DeleteSession的典型用法代码示例。如果您正苦于以下问题:Java DeleteSession类的具体用法?Java DeleteSession怎么用?Java DeleteSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DeleteSession类属于org.openqa.selenium.remote.server.handler包,在下文中一共展示了DeleteSession类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkExpiry

import org.openqa.selenium.remote.server.handler.DeleteSession; //导入依赖的package包/类
void checkExpiry() {
  for (SessionId sessionId : driverSessions.getSessions()) {
    Session session = driverSessions.get(sessionId);
    if (session != null) {
      boolean useDeleteSession = false;
      boolean killed = false;

      boolean inUse = session.isInUse();
      if (!inUse && session.isTimedOut(clientGoneTimeout)) {
        useDeleteSession = true;
        log.info("Session " + session.getSessionId() + " deleted due to client timeout");
      }
      if (inUse && session.isTimedOut(insideBrowserTimeout)) {
        WebDriver driver = session.getDriver();
        if (driver instanceof EventFiringWebDriver){
          driver = ((EventFiringWebDriver)driver).getWrappedDriver();
        }
        if (driver instanceof Killable) {
          //session.interrupt();
          ((Killable) driver).kill();
          killed = true;
          log.warning("Browser killed and session " + session.getSessionId() + " terminated due to in-browser timeout.");
        } else {
          useDeleteSession = true;
          log.warning("Session " + session.getSessionId() + " deleted due to in-browser timeout. " +
                      "Terminating driver with DeleteSession since it does not support Killable, "
                      + "the driver in question does not support selenium-server timeouts fully");
        }
      }

      if (useDeleteSession) {
        DeleteSession deleteSession = new DeleteSession(session);
        try {
          deleteSession.call();
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }

      if (useDeleteSession || killed) {
        driverSessions.deleteSession(sessionId);
        final PerSessionLogHandler logHandler = LoggingManager.perSessionLogHandler();
        logHandler.transferThreadTempLogsToSessionLogs(sessionId);
        logHandler.removeSessionLogs(sessionId);
      }
    }
  }
}
 
开发者ID:alexkogon,项目名称:grid-refactor-remote-server,代码行数:49,代码来源:SessionCleaner.java


注:本文中的org.openqa.selenium.remote.server.handler.DeleteSession类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。