private void doLogin() throws UnsupportedEncodingException { webDriver.get(baseUrl + "/login"); webDriver.findElement(By.name("username")).sendKeys(testAccounts.getUserName()); webDriver.findElement(By.name("password")).sendKeys(testAccounts.getPassword()); webDriver.findElement(By.xpath("//input[@value='Sign in']")).click(); Cookie currentUserCookie = webDriver.manage().getCookieNamed("Current-User"); CurrentUserInformation currentUserInformation = JsonUtils.readValue(URLDecoder.decode(currentUserCookie.getValue(), "UTF-8"), CurrentUserInformation.class); String userId = currentUserInformation.getUserId(); testPage = "file://" + System.getProperty("user.dir") + "/src/test/resources/session_frame_test.html#" + userId; }
private void login(String zoneUrl, String userName, String password) { webDriver.get(zoneUrl + "/logout.do"); webDriver.get(zoneUrl + "/"); Cookie beforeLogin = webDriver.manage().getCookieNamed("JSESSIONID"); assertNotNull(beforeLogin); assertNotNull(beforeLogin.getValue()); webDriver.findElement(By.linkText("My OIDC Provider")).click(); Assert.assertThat(webDriver.getCurrentUrl(), containsString(baseUrl)); webDriver.findElement(By.name("username")).sendKeys(userName); webDriver.findElement(By.name("password")).sendKeys(password); webDriver.findElement(By.xpath("//input[@value='Sign in']")).click(); Assert.assertThat(webDriver.getCurrentUrl(), containsString(zoneUrl)); assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?")); Cookie afterLogin = webDriver.manage().getCookieNamed("JSESSIONID"); assertNotNull(afterLogin); assertNotNull(afterLogin.getValue()); assertNotEquals(beforeLogin.getValue(), afterLogin.getValue()); }
webDriver.get(spZoneUrl + "/"); assertEquals(spZone.getName(), webDriver.getTitle()); Cookie beforeLogin = webDriver.manage().getCookieNamed("JSESSIONID"); assertNotNull(beforeLogin); assertNotNull(beforeLogin.getValue()); webDriver.findElement(By.xpath("//input[@value='Sign in']")).click(); assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?")); Cookie afterLogin = webDriver.manage().getCookieNamed("JSESSIONID"); assertNotNull(afterLogin); assertNotNull(afterLogin.getValue());
public static void deleteTrackingOptInCookie(WikiaWebDriver driver) { Cookie optInCookie = driver.manage().getCookieNamed("tracking-opt-in-status"); if (optInCookie != null) { driver.manage().deleteCookie(optInCookie); } }
/** * @return the session ID for the driver, or null if no session. */ public String getSessionId() { Cookie cookie = getWebDriver().manage().getCookieNamed(SESSION_ID_COOKIE); if (cookie == null) { return null; } return cookie.getValue(); }
/** * @param value Get cookie by nam */ @JDIAction("Get cookie '{0}'") public static Cookie getCookie(String value) { return manage().getCookieNamed(value); } /**
@Test(groups = {"mobile-wiki-tracking-opt-in"}) @Execute(asUser = User.USER, trackingOptIn = true) public void loggedInUserInEUShouldNotGetModalIfOptedIn() { TrackingOptInPage.setGeoCookie(driver, "EU", "DE"); new ArticlePage().open(); Log.info("Geo cookie: ", driver.manage().getCookieNamed("Geo").getValue()); Assertion.assertFalse(new TrackingOptInPage().isVisible()); }
@Execute(asUser = User.ANONYMOUS, trackingOptIn = false) @Test(groups = { "mobile-wiki-tracking-opt-in"}, dataProviderClass = TrackingOptInDataProvider.class, dataProvider = "GDPRCountriesForTest") public void testModalVisibilityForAnon(String continent, String country, boolean shouldGetModal) { TrackingOptInPage.setGeoCookie(driver, continent, country); new ArticlePage().open(); Log.info("Geo cookie: ", driver.manage().getCookieNamed("Geo").getValue()); Assertion.assertEquals(new TrackingOptInPage().isVisible(), shouldGetModal); }
/** * @return the session ID for the driver, or null if no session. */ public String getSessionId() { Cookie cookie = driver.manage().getCookieNamed(SESSION_ID_COOKIE); if (cookie == null) { return null; } return cookie.getValue(); }
/** * Returns the value of the cookie with the specified name, or throws an error if the cookie is not present. * * @param name the name of the cookie * @return the value of the cookie */ public String getCookieByName(String name) { Cookie cookie = driver.manage().getCookieNamed(name); return cookie == null ? null : cookie.getValue(); }
public final String getCookieByName(final String name) { if (driver.manage().getCookieNamed(name) == null) { return null; } return driver.manage().getCookieNamed(name).getValue(); }
@Test void saveCookieToVarTest() { Cookie cookie = new Cookie("cookieName", "123"); when(webDriver.manage().getCookieNamed("cookieName")).thenReturn(cookie); dmbs.saveCookieToVar("cookieName", "varName"); assertEquals(cookie, akitaScenario.getVar("varName")); }
/** * Gets current browser's cookie with supplied name. * @param cookieName name of cookie to return. * @return cookie, if present, null otherwise. */ public Cookie getCookie(String cookieName) { return driver().manage().getCookieNamed(cookieName); }
@Override public Boolean execute(Context context, String... args) { return context.getWrappedDriver().manage().getCookieNamed(args[ARG_COOKIE_NAME]) != null; } }
@Execute(asUser = User.USER, trackingOptIn = false) @Test(groups = { "mobile-wiki-tracking-opt-in"}, dataProviderClass = TrackingOptInDataProvider.class, dataProvider = "GDPRCountriesForTest") public void testModalVisibilityForLoggedInWhoNeverOptedIn( String continent, String country, boolean shouldGetModal ) { TrackingOptInPage.setGeoCookie(driver, continent, country); new ArticlePage().open(); Log.info("Geo cookie: ", driver.manage().getCookieNamed("Geo").getValue()); Assertion.assertEquals(new TrackingOptInPage().isVisible(), shouldGetModal); }
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), Matchers.containsString("Where to?")); Cookie cookie= webDriver.manage().getCookieNamed("JSESSIONID");
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), Matchers.containsString("Where to?")); Cookie cookie= webDriver.manage().getCookieNamed("JSESSIONID");
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?")); Cookie cookie = webDriver.manage().getCookieNamed("JSESSIONID");
Cookie cookie = webDriver.manage().getCookieNamed("JSESSIONID");
@Test public void testCsrfIsResetDuringLoginPageReload() { webDriver.get(baseUrl + "/login"); String csrf1 = webDriver.manage().getCookieNamed(CookieBasedCsrfTokenRepository.DEFAULT_CSRF_COOKIE_NAME).getValue(); webDriver.get(baseUrl + "/login"); String csrf2 = webDriver.manage().getCookieNamed(CookieBasedCsrfTokenRepository.DEFAULT_CSRF_COOKIE_NAME).getValue(); assertNotEquals(csrf1, csrf2); }