@Test public void shouldHandleEmptyCookiesForBrowsersThatRequireJavaScript() { when(((HasCapabilities) mockDriver).getCapabilities()).thenReturn(DesiredCapabilities.safari()); doReturn("").when((JavascriptExecutor) mockDriver).executeScript("return (document.cookie);"); CinnamonWebDriverOptions options = new CinnamonWebDriverOptions(mockDriver); assertThat(options.getCookies(), emptyCollectionOf(Cookie.class)); }
@Override public Set<Cookie> getCookies() { if (requiresJavaScript) { return Stream.of(((String) js.executeScript("return (document.cookie);")).split(";")).filter(s -> !s.isEmpty()).map(c -> { String[] parts = c.trim().split("=", -1); return new Cookie(parts[0], parts[1]); }).collect(Collectors.toSet()); } return delegate.getCookies(); }
CinnamonWebDriverOptions implements WebDriver.Options { @Override public Set<Cookie> getCookies() { if (requiresJavaScript) { return Stream.of(((String) js.executeScript("return (document.cookie);")).split(";")).filter(s -> !s.isEmpty()).map(c -> { String[] parts = c.trim().split("=", -1); return new Cookie(parts[0], parts[1]); }).collect(Collectors.toSet()); } return delegate.getCookies(); } }
CinnamonWebDriverOptions implements WebDriver.Options { @Override public Set<Cookie> getCookies() { if (requiresJavaScript) { return Stream.of(((String) js.executeScript("return (document.cookie);")).split(";")).filter(s -> !s.isEmpty()).map(c -> { String[] parts = c.trim().split("=", -1); return new Cookie(parts[0], parts[1]); }).collect(Collectors.toSet()); } return delegate.getCookies(); } CinnamonWebDriverOptions(final WebDriver webDriver); }
CinnamonWebDriverOptions implements WebDriver.Options { @Override public Set<Cookie> getCookies() { if (requiresJavaScript) { return Stream.of(((String) js.executeScript("return (document.cookie);")).split(";")).filter(s -> !s.isEmpty()).map(c -> { String[] parts = c.trim().split("=", -1); return new Cookie(parts[0], parts[1]); }).collect(Collectors.toSet()); } return delegate.getCookies(); } CinnamonWebDriverOptions(final WebDriver webDriver); @Override void addCookie(Cookie cookie); @Override void deleteCookieNamed(String name); @Override void deleteCookie(Cookie cookie); @Override void deleteAllCookies(); @Override Set<Cookie> getCookies(); @Override Cookie getCookieNamed(String name); @Override WebDriver.Timeouts timeouts(); @Override WebDriver.ImeHandler ime(); @Override WebDriver.Window window(); @Override Logs logs(); }
CinnamonWebDriverOptions implements WebDriver.Options { @Override public Set<Cookie> getCookies() { if (requiresJavaScript) { return Stream.of(((String) js.executeScript("return (document.cookie);")).split(";")).filter(s -> !s.isEmpty()).map(c -> { String[] parts = c.trim().split("=", -1); return new Cookie(parts[0], parts[1]); }).collect(Collectors.toSet()); } return delegate.getCookies(); } CinnamonWebDriverOptions(final WebDriver webDriver); @Override void addCookie(Cookie cookie); @Override void deleteCookieNamed(String name); @Override void deleteCookie(Cookie cookie); @Override void deleteAllCookies(); @Override Set<Cookie> getCookies(); @Override Cookie getCookieNamed(String name); @Override WebDriver.Timeouts timeouts(); @Override WebDriver.ImeHandler ime(); @Override WebDriver.Window window(); @Override Logs logs();  }