public static JobConfig.Builder exampleConfigBuilder() { return configBuilder() .withUrls(ImmutableMap.of("http://www.example.com", new UrlConfig( ImmutableList.of("/", "someOtherPath"), DEFAULT_MAX_DIFF, ImmutableList.of( new Cookie("exampleCookieName", "exampleValue", "http://www.example.com", "/", new Date(1000L), true) ), ImmutableMap.of("live", "www"), ImmutableMap.of("exampleLocalStorageKey", "value"), ImmutableMap.of("exampleSessionStorageKey", "value"), ImmutableList.of(600, 800, 1000), DEFAULT_MAX_SCROLL_HEIGHT, DEFAULT_WAIT_AFTER_PAGE_LOAD, DEFAULT_WAIT_AFTER_SCROLL, DEFAULT_WAIT_FOR_NO_ANIMATION_AFTER_SCROLL, DEFAULT_WARMUP_BROWSER_CACHE_TIME, "console.log('This is JavaScript!')", DEFAULT_WAIT_FOR_FONTS_TIME, new HttpCheckConfig(true), DEFAULT_MAX_COLOR_DIFF_PER_PIXEL, false ))); }
public static UrlConfig getExpectedUrlConfigForOttoDe() { return new UrlConfig(ImmutableList.of("/", "multimedia"), 0.05f, ImmutableList.of(new Cookie("testcookie1", "true"), new Cookie("testcookie2", "1")), ImmutableMap.of("live", "www"), ImmutableMap.of("teststorage", "{'testkey':{'value':true,'timestamp':9467812242358}}"), ImmutableMap.of("testsession", "{'testkey':{'value':true,'timestamp':9467812242358}}"), ImmutableList.of(600, 800, 1200), 50000, 2, 1, 0, 3, "console.log('Moin!');", 0, new HttpCheckConfig(), 1, false); }
@Test public void shouldSetCookiesThroughJavascript() { //given Cookie cookieOne = new Cookie("someName", "someValue", "someDomain", "somePath", new Date(10000L), true); Cookie cookieTwo = new Cookie("someOtherName", "someOtherValue", "someOtherDomain", "someOtherPath", new Date(100000067899L), false); //when testee.setCookiesPhantomJS(ImmutableList.of(cookieOne, cookieTwo)); //then verify(webDriverMock).executeScript("document.cookie = 'someName=someValue;path=somePath;domain=someDomain;secure;expires=01 Jan 1970 00:00:10 GMT;'"); verify(webDriverMock).executeScript("document.cookie = 'someOtherName=someOtherValue;path=someOtherPath;domain=someOtherDomain;expires=03 Mar 1973 09:47:47 GMT;'"); }
@Test public void shouldSetCookies() { //given ArgumentCaptor<org.openqa.selenium.Cookie> cookieCaptor = ArgumentCaptor.forClass(org.openqa.selenium.Cookie.class); Cookie cookieOne = new Cookie("someName", "someValue", "someDomain", "somePath", new Date(10000L), true); Cookie cookieTwo = new Cookie("someOtherName", "someOtherValue", "someOtherDomain", "someOtherPath", new Date(10000000000L), false); //when testee.setCookies(ImmutableList.of(cookieOne, cookieTwo)); //then verify(webDriverOptionsMock, times(2)).addCookie(cookieCaptor.capture()); List<org.openqa.selenium.Cookie> capturedCookies = cookieCaptor.getAllValues(); assertEquals("someName", capturedCookies.get(0).getName()); assertEquals("someValue", capturedCookies.get(0).getValue()); assertEquals("someDomain", capturedCookies.get(0).getDomain()); assertEquals("somePath", capturedCookies.get(0).getPath()); assertEquals(new Date(10000L), capturedCookies.get(0).getExpiry()); Assert.assertTrue(capturedCookies.get(0).isSecure()); assertEquals("someOtherName", capturedCookies.get(1).getName()); assertEquals("someOtherValue", capturedCookies.get(1).getValue()); assertEquals("someOtherDomain", capturedCookies.get(1).getDomain()); assertEquals("someOtherPath", capturedCookies.get(1).getPath()); assertEquals(new Date(10000000000L), capturedCookies.get(1).getExpiry()); assertFalse(capturedCookies.get(1).isSecure()); }
ImmutableList.of("/"), 0f, ImmutableList.of(new Cookie("testcookiename", "testcookievalue")), ImmutableMap.of(), ImmutableMap.of("key", "value"),
@Test public void shouldSetCookieOnCorrectPath() throws ConfigValidationException { UrlConfig urlConfig = UrlConfig.urlConfigBuilder() .withCookie(new Cookie("CookieName", "CookieValue")) .withPaths(ImmutableList.of("/")).build(); JobConfig jobConfig = localTestConfig("somerootpath/somevalidsubpath", Browser.Type.CHROME_HEADLESS, true, urlConfig); runJLineup(jobConfig, Step.before); }
@Test public void shouldNotAppendSlashToDomain() throws ConfigValidationException { UrlConfig urlConfig = UrlConfig.urlConfigBuilder().withCookie(new Cookie("CookieName", "CookieValue")).build(); JobConfig jobConfig = localTestConfig("params?param1=1¶m2=2", Browser.Type.CHROME_HEADLESS, true, urlConfig); runJLineup(jobConfig, Step.before); }