@BeforeMethod(alwaysRun = true) public static void clearSession() { if(requiresReset.get()) { try { if (DriverType.isNative()) { getDriver().getWrappedAppiumDriver().resetApp(); } else { getDriver().manage().deleteAllCookies(); } } catch (SessionNotFoundException e) { logger.error("Session quit unexpectedly."); } } else { requiresReset.set(Boolean.TRUE); } }
public WebDriver getBySessionId(String sessionId) throws SessionNotFoundException { for (WebDriver driver : driversPool) { if (driver instanceof RemoteWebDriver) { if (((RemoteWebDriver) driver).getSessionId().toString().equals(sessionId)) { return driver; } } } throw new SessionNotFoundException(format("Driver with session id %s has never been created", sessionId)); }
private void throwUpIfSessionTerminated(SessionId sessId) throws SessionNotFoundException { if (sessId == null) return; Session session = sessions.get(sessId); final boolean isTerminated = session == null; if (isTerminated){ throw new SessionNotFoundException(); } }