org.openqa.selenium.html5.SessionStorage Java Examples

The following examples show how to use org.openqa.selenium.html5.SessionStorage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutoModuleProxy.java    From phoenix.webui.framework with Apache License 2.0 6 votes vote down vote up
/**
 * 保存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);
    }
}
 
Example #2
Source File: UtilsTest.java    From selenium with Apache License 2.0 6 votes vote down vote up
@Test
public void providesRemoteAccessToWebStorage() {
  DesiredCapabilities caps = new DesiredCapabilities();
  caps.setCapability(CapabilityType.SUPPORTS_WEB_STORAGE, true);

  CapableDriver driver = mock(CapableDriver.class);
  when(driver.getCapabilities()).thenReturn(caps);

  WebStorage storage = Utils.getWebStorage(driver);

  LocalStorage localStorage = storage.getLocalStorage();
  SessionStorage sessionStorage = storage.getSessionStorage();

  localStorage.setItem("foo", "bar");
  sessionStorage.setItem("bim", "baz");

  verify(driver).execute(DriverCommand.SET_LOCAL_STORAGE_ITEM, ImmutableMap.of(
      "key", "foo", "value", "bar"));
  verify(driver).execute(DriverCommand.SET_SESSION_STORAGE_ITEM, ImmutableMap.of(
      "key", "bim", "value", "baz"));
}
 
Example #3
Source File: AutoModuleProxy.java    From phoenix.webui.framework with Apache License 2.0 5 votes vote down vote up
/**
 * 加载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;
}
 
Example #4
Source File: CurrentWebDriver.java    From webtau with Apache License 2.0 4 votes vote down vote up
@Override
public SessionStorage getSessionStorage() {
    return ((WebStorage)getDriver()).getSessionStorage();
}
 
Example #5
Source File: FirefoxDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public SessionStorage getSessionStorage() {
  return webStorage.getSessionStorage();
}
 
Example #6
Source File: OperaDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public SessionStorage getSessionStorage() {
  return webStorage.getSessionStorage();
}
 
Example #7
Source File: ChromiumDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public SessionStorage getSessionStorage() {
  return webStorage.getSessionStorage();
}
 
Example #8
Source File: RemoteWebStorage.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public SessionStorage getSessionStorage() {
  return new RemoteSessionStorage(executeMethod);
}
 
Example #9
Source File: TestEdgeHtmlDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public SessionStorage getSessionStorage() {
  return webStorage.getSessionStorage();
}
 
Example #10
Source File: TestEdgeDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public SessionStorage getSessionStorage() {
  return webStorage.getSessionStorage();
}