org.openqa.selenium.html5.LocalStorage Java Examples

The following examples show how to use org.openqa.selenium.html5.LocalStorage. 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
private void saveLocalStorage(String account)
{
    WebDriver driver = util.getEngine().getDriver();
    if(driver instanceof WebStorage)
    {
        WebStorage webStorage = (WebStorage) driver;
        LocalStorage localStorage = webStorage.getLocalStorage();

        Properties pro = new Properties();
        for(String key : localStorage.keySet())
        {
            pro.setProperty(key, localStorage.getItem(key));
        }

        PathUtil.proStore(pro, "localStorage." + 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: LocalStorageProvider.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Override
public LocalStorage getLocalStorage()
{
    RemoteWebDriver driver = webDriverProvider.getUnwrapped(RemoteWebDriver.class);
    if (!webDriverManager.isTypeAnyOf(WebDriverType.SAFARI) && isWebStorageEnabled(driver))
    {
        return new RemoteLocalStorage(new RemoteExecuteMethod(driver));
    }
    return new JavascriptLocalStorage(javascriptActions);
}
 
Example #4
Source File: LocalStorageProviderTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
private void testGetLocalStorage(Boolean safariDriver, Boolean webStorageEnabled,
        Class<? extends LocalStorage> expectedStorageClass)
{
    RemoteWebDriver driver = mock(RemoteWebDriver.class);
    Mockito.lenient().when(webDriverProvider.getUnwrapped(RemoteWebDriver.class)).thenReturn(driver);
    Mockito.lenient().when(webDriverManager.isTypeAnyOf(WebDriverType.SAFARI)).thenReturn(safariDriver);
    Capabilities capabilities = mock(Capabilities.class);
    Mockito.lenient().when(driver.getCapabilities()).thenReturn(capabilities);
    Mockito.lenient().when(capabilities.getCapability(CapabilityType.SUPPORTS_WEB_STORAGE))
            .thenReturn(webStorageEnabled);
    assertTrue(expectedStorageClass.isInstance(localStorageProvider.getLocalStorage()));
}
 
Example #5
Source File: AutoModuleProxy.java    From phoenix.webui.framework with Apache License 2.0 5 votes vote down vote up
private boolean loadLocalStorage(String accountNameValue, Map<String, String> customMap)
{
    WebDriver webDriver = util.getEngine().getDriver();
    if(webDriver instanceof WebStorage)
    {
        WebStorage webStorage = (WebStorage) webDriver;
        LocalStorage localStorage = webStorage.getLocalStorage();

        Properties pro = new Properties();
        if(PathUtil.proLoad(pro, "localStorage." + accountNameValue))
        {
            if(pro.isEmpty())
            {
                return false;
            }
            
            pro.putAll(customMap);

            pro.stringPropertyNames().parallelStream().forEach((key) -> {
            	localStorage.setItem(key, pro.getProperty(key));
            });

            return true;
        }
    }

    return false;
}
 
Example #6
Source File: LocalStorageManager.java    From vividus with Apache License 2.0 4 votes vote down vote up
private LocalStorage getLocalStorage()
{
    return localStorageProvider.getLocalStorage();
}
 
Example #7
Source File: CurrentWebDriver.java    From webtau with Apache License 2.0 4 votes vote down vote up
@Override
public LocalStorage getLocalStorage() {
    return ((WebStorage)getDriver()).getLocalStorage();
}
 
Example #8
Source File: FirefoxDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public LocalStorage getLocalStorage() {
  return webStorage.getLocalStorage();
}
 
Example #9
Source File: OperaDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public LocalStorage getLocalStorage() {
  return webStorage.getLocalStorage();
}
 
Example #10
Source File: ChromiumDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public LocalStorage getLocalStorage() {
  return webStorage.getLocalStorage();
}
 
Example #11
Source File: RemoteWebStorage.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public LocalStorage getLocalStorage() {
  return new RemoteLocalStorage(executeMethod);
}
 
Example #12
Source File: TestEdgeHtmlDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public LocalStorage getLocalStorage() {
  return webStorage.getLocalStorage();
}
 
Example #13
Source File: TestEdgeDriver.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public LocalStorage getLocalStorage() {
  return webStorage.getLocalStorage();
}
 
Example #14
Source File: ILocalStorageProvider.java    From vividus with Apache License 2.0 votes vote down vote up
LocalStorage getLocalStorage();