List of usage examples for org.openqa.selenium Cookie getValue
public String getValue()
From source file:ccnu.computer.crawler.WeiboCN.java
public static String concatCookie(HtmlUnitDriver driver) { Set<Cookie> cookieSet = driver.manage().getCookies(); StringBuilder sb = new StringBuilder(); for (Cookie cookie : cookieSet) { sb.append(cookie.getName() + "=" + cookie.getValue() + ";"); }//ww w . j av a 2 s . com String result = sb.toString(); return result; }
From source file:com.citrix.g2w.webdriver.util.FileDownloader.java
License:Open Source License
/** * Load in all the cookies WebDriver currently knows about so that we can * mimic the browser cookie state.//from www. j a v a 2 s .co m * * @param seleniumCookieSet * @return mimicWebDriverCookieStore */ private BasicCookieStore mimicCookieState(Set<Cookie> seleniumCookieSet) { BasicCookieStore mimicWebDriverCookieStore = new BasicCookieStore(); for (Cookie seleniumCookie : seleniumCookieSet) { BasicClientCookie duplicateCookie = new BasicClientCookie(seleniumCookie.getName(), seleniumCookie.getValue()); duplicateCookie.setDomain(seleniumCookie.getDomain()); duplicateCookie.setSecure(seleniumCookie.isSecure()); duplicateCookie.setExpiryDate(seleniumCookie.getExpiry()); duplicateCookie.setPath(seleniumCookie.getPath()); mimicWebDriverCookieStore.addCookie(duplicateCookie); } return mimicWebDriverCookieStore; }
From source file:com.cognifide.aet.job.common.comparators.cookie.CookieComparator.java
License:Apache License
private ComparatorStepResult testCookie(Set<Cookie> cookies) { boolean testResult = false; for (Cookie cookie : cookies) { if (cookie.getName().equals(name) && (value == null || value.equals(cookie.getValue()))) { testResult = true;// ww w . j ava 2 s.c o m break; } } CookieTestComparatorResult result = new CookieTestComparatorResult(compareAction, cookies, name, value); final String artifactId = artifactsDAO.saveArtifactInJsonFormat(properties, result); return new ComparatorStepResult(artifactId, testResult ? ComparatorStepResult.Status.PASSED : ComparatorStepResult.Status.FAILED); }
From source file:com.cognifide.aet.job.common.modifiers.login.LoginModifier.java
License:Apache License
@Override public CollectorStepResult collect() throws ProcessingException { if (config.isForceLogin() || !hasLoginToken()) { int trialNumber = 0; boolean successfullyLogged = false; while (trialNumber < config.getRetrialNumber() && !successfullyLogged) { if (trialNumber > 0) { delayBeforeLoginCheckOrReattempt(); }//from w w w. ja v a 2s .c om try { login(); successfullyLogged = true; } catch (ProcessingException e) { LOGGER.warn("Attempt {}/{} to log in to {} failed.", trialNumber + 1, config.getRetrialNumber(), config.getLoginPage(), e); } trialNumber++; } if (!successfullyLogged) { throw new ProcessingException("All attempts to log in to " + config.getLoginPage() + " failed."); } } else { LOGGER.info("User is authenticated."); Cookie cookie = getLoginToken(); webCommunicationWrapper.getHttpRequestBuilder().addCookie(cookie.getName(), cookie.getValue()); } return CollectorStepResult.newModifierResult(); }
From source file:com.cognifide.aet.job.common.modifiers.login.LoginModifier.java
License:Apache License
private void login() throws ProcessingException { loginToForm();/*from w w w . j a v a 2s. co m*/ delayBeforeLoginCheckOrReattempt(); Cookie authCookie = getLoginToken(); if (authCookie == null) { throw new ProcessingException("Unable to acquire Cookie; check credentials."); } webCommunicationWrapper.getHttpRequestBuilder().addCookie(authCookie.getName(), authCookie.getValue()); LOGGER.info("User has been authenticated"); }
From source file:com.cognifide.qa.bb.aem.AemAuthCookieFactory.java
License:Apache License
private Cookie findAuthenticationCookie(List<org.apache.http.cookie.Cookie> cookies) { for (org.apache.http.cookie.Cookie cookie : cookies) { if (properties.getProperty(ConfigKeys.LOGIN_TOKEN, DEFAULT_LOGIN_TOKEN).equals(cookie.getName())) { return new Cookie(cookie.getName(), cookie.getValue(), cookie.getDomain(), cookie.getPath(), cookie.getExpiryDate()); }// w w w . j a v a 2s . c o m } return null; }
From source file:com.dhenton9000.filedownloader.FileDownloader.java
License:Apache License
/** * Load in all the cookies WebDriver currently knows about so that we can mimic the browser cookie state * * @param seleniumCookieSet Set<Cookie> *//*from w ww.j av a 2 s.c o m*/ private BasicCookieStore mimicCookieState(Set<Cookie> seleniumCookieSet) { BasicCookieStore copyOfWebDriverCookieStore = new BasicCookieStore(); for (Cookie seleniumCookie : seleniumCookieSet) { BasicClientCookie duplicateCookie = new BasicClientCookie(seleniumCookie.getName(), seleniumCookie.getValue()); duplicateCookie.setDomain(seleniumCookie.getDomain()); duplicateCookie.setSecure(seleniumCookie.isSecure()); duplicateCookie.setExpiryDate(seleniumCookie.getExpiry()); duplicateCookie.setPath(seleniumCookie.getPath()); copyOfWebDriverCookieStore.addCookie(duplicateCookie); } return copyOfWebDriverCookieStore; }
From source file:com.fmb.common.BrowserEmulator.java
License:Apache License
public void getCookie() { Set<Cookie> cookies = browserCore.manage().getCookies(); for (Cookie c : cookies) { System.out.println(c.getDomain() + ", " + c.getName() + ", " + c.getValue() + "," + c.getExpiry() + ", " + c.getPath());/*from ww w. j a va2s . c o m*/ } logger.info("get cookie"); }
From source file:com.fmb.common.BrowserEmulator.java
License:Apache License
public String getCookieByName(String cookiename) { Cookie cookie = browserCore.manage().getCookieNamed(cookiename); return cookie.getValue(); }
From source file:com.ggasoftware.uitest.utils.FileUtil.java
License:Open Source License
/** * Get Cookie from WebDriver browser session. * * @return cookieStore from WebDriver browser session. */// w ww . j a v a 2 s .co m private static CookieStore seleniumCookiesToCookieStore() { Set<Cookie> seleniumCookies = WebDriverWrapper.getDriver().manage().getCookies(); CookieStore cookieStore = new BasicCookieStore(); for (Cookie seleniumCookie : seleniumCookies) { BasicClientCookie basicClientCookie = new BasicClientCookie(seleniumCookie.getName(), seleniumCookie.getValue()); basicClientCookie.setDomain(seleniumCookie.getDomain()); basicClientCookie.setExpiryDate(seleniumCookie.getExpiry()); basicClientCookie.setPath(seleniumCookie.getPath()); cookieStore.addCookie(basicClientCookie); } return cookieStore; }