RemoteWebDriver driver = null;
// try to reuse the session
// retrieve the session id
ReusedSession stored = sessionStore.get().pull(initParam);
// get all the stored sessions for given initParam
while (stored != null) {
SessionId reusedSessionId = stored.getSessionId();
Capabilities reusedCapabilities = stored.getCapabilities();
try {
driver = ReusableRemoteWebDriver.fromReusedSession(remoteAddress, reusedCapabilities, reusedSessionId);
break;
} catch (UnableReuseSessionException ex) {
log.log(Level.WARNING, "Unable to reuse session: {0}", stored.getSessionId());
}
stored = sessionStore.get().pull(initParam);
}