/** * 保存sessionStorage信息 * @param account */ private void saveSessionStorage(String account) { WebDriver driver = util.getEngine().getDriver(); if(driver instanceof WebStorage) { WebStorage webStorage = (WebStorage) driver; SessionStorage sessionStorage = webStorage.getSessionStorage(); Properties pro = new Properties(); for(String key : sessionStorage.keySet()) { pro.setProperty(key, sessionStorage.getItem(key)); } PathUtil.proStore(pro, "sessionStorage." + account); } }
/** * 加载sessionStorage信息 * @param accountNameValue * @return */ private boolean loadSessionStorage(String accountNameValue, Map<String, String> customMap) { WebDriver webDriver = util.getEngine().getDriver(); if(webDriver instanceof WebStorage) { WebStorage webStorage = (WebStorage) webDriver; SessionStorage sessionStorage = webStorage.getSessionStorage(); Properties pro = new Properties(); if(PathUtil.proLoad(pro, "sessionStorage." + accountNameValue)) { if(pro.isEmpty()) { return false; } pro.putAll(customMap); pro.stringPropertyNames().parallelStream().forEach((key) -> { sessionStorage.setItem(key, pro.getProperty(key)); }); return true; } } return false; }
@Override public SessionStorage getSessionStorage() { return new JSSessionStorage(this.getDriverContext()); }
@Override public SessionStorage getSessionStorage() { return this.webStorage.getSessionStorage(); }