Ejemplo n.º 1
0
 /**
  * Ends a browser session.
  *
  * @param sessionId the id of the session to be ended
  * @param configuration Remote Control configuration. Cannot be null.
  * @param ensureClean if clean sessions (e.g. no leftover cookies) are required.
  */
 protected void endBrowserSession(
     boolean forceClose,
     String sessionId,
     RemoteControlConfiguration configuration,
     boolean ensureClean) {
   BrowserSessionInfo sessionInfo = lookupInfoBySessionId(sessionId, activeSessions);
   if (null != sessionInfo) {
     activeSessions.remove(sessionInfo);
     try {
       if (forceClose || !configuration.reuseBrowserSessions()) {
         shutdownBrowserAndClearSessionData(sessionInfo);
       } else {
         if (null != sessionInfo.session) { // optional field
           sessionInfo.session.reset(sessionInfo.baseUrl);
         }
         // mark what time this session was ended
         sessionInfo.lastClosedAt = System.currentTimeMillis();
         availableSessions.add(sessionInfo);
       }
     } finally {
       LoggingManager.perSessionLogHandler().removeSessionLogs(new SessionId(sessionId));
       if (ensureClean) {
         // need to add this to the launcher API.
         // sessionInfo.launcher.restoreOriginalSessionData();
       }
     }
   } else {
     // look for it in the available sessions.
     sessionInfo = lookupInfoBySessionId(sessionId, availableSessions);
     if (null != sessionInfo && (forceClose || !configuration.reuseBrowserSessions())) {
       try {
         availableSessions.remove(sessionInfo);
         shutdownBrowserAndClearSessionData(sessionInfo);
       } finally {
         LoggingManager.perSessionLogHandler().removeSessionLogs(new SessionId(sessionId));
         if (ensureClean) {
           // sessionInfo.launcher.restoreOriginalSessionData();
         }
       }
     }
   }
 }
Ejemplo n.º 2
0
 /**
  * Gets a new browser session, using the SeleniumServer static fields to populate parameters.
  *
  * @param browserString
  * @param startURL
  * @param extensionJs per-session user extension Javascript
  * @param configuration Remote Control configuration. Cannot be null.
  * @return the BrowserSessionInfo for the new browser session.
  * @throws RemoteCommandException
  */
 public BrowserSessionInfo getNewBrowserSession(
     String browserString,
     String startURL,
     String extensionJs,
     Capabilities browserConfigurations,
     RemoteControlConfiguration configuration)
     throws RemoteCommandException {
   return getNewBrowserSession(
       browserString,
       startURL,
       extensionJs,
       browserConfigurations,
       configuration.reuseBrowserSessions(),
       configuration.isEnsureCleanSession(),
       configuration);
 }