Package org.openqa.selenium

Examples of org.openqa.selenium.Cookie


    @Test
    @InSequence(2)
    public void testCookieWasStored(@Drone @Reusable WebDriver driver) {
        driver.get(HUB_URL.toString());
        driver.manage().addCookie(new Cookie("foo", "bar"));
        Assert.assertNotNull("Cookie was stored", driver.manage().getCookieNamed("foo"));
        Assert.assertEquals("Cookie was stored", "bar", driver.manage().getCookieNamed("foo").getValue());
    }
View Full Code Here


    @Test
    @InSequence(5)
    public void testCookieWasStoredAgain(@Drone @ReuseCookies WebDriver driver) {
        driver.get(HUB_URL.toString());
        driver.manage().addCookie(new Cookie("foo", "bar"));
        Assert.assertNotNull("Cookie was stored", driver.manage().getCookieNamed("foo"));
        Assert.assertEquals("Cookie was stored", "bar", driver.manage().getCookieNamed("foo").getValue());
    }
View Full Code Here

            userField.sendKeys(username);
            passwordField.sendKeys(password);

            submit.click();

            Cookie session = driver.manage().getCookieNamed("JSESSIONID");
            sessionId = session.getValue();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            if(driver != null) {
                driver.close();
View Full Code Here

                WebDriver driver = event.getInstance().asInstance(WebDriver.class);
                // We need to navigate somewhere before we can set a cookie.
                // https://www.w3.org/Bugs/Public/show_bug.cgi?id=20975
                driver.get(holder.get().getURI() + "/../");
                driver.manage().deleteAllCookies();
                driver.manage().addCookie(new Cookie("JSESSIONID", holder.get().getSessionId()));
            }
        }
View Full Code Here

        String value = cookie.optString("value");
        String domain = cookie.optString("domain");
        String path = cookie.optString("path");
        Date expiry = new Date(cookie.optLong("expires"));
        boolean isSecure = cookie.optBoolean("secure");
        Cookie c = new Cookie(name, value, domain, path, expiry, isSecure);
        res.add(c);
      }
      return res;
    } else {
      // TODO
View Full Code Here

        String contextPath = browsersSwitched ? contextPath1 : contextPath2;
      
        // We navigate to the home page on the second server, just to set the cookies
        driver.navigate().to(new URL(contextPath));
        driver.manage().deleteAllCookies();
        driver.manage().addCookie(new Cookie("JSESSIONID", sid));
       
        // Now we navigate for reals
        driver.navigate().to(new URL(contextPath + "/" + address));
       
        browsersSwitched = !browsersSwitched;
View Full Code Here

    List<CookieMngProtos.Cookie> cookies = list.getCookieListList();
    Set<Cookie> result = Sets.newHashSet();

    for (CookieMngProtos.Cookie cookie : cookies) {
      result.add(new Cookie(cookie.getName(), cookie.getValue(),
                            cookie.getDomain(), cookie.getPath(), new Date(cookie.getExpires()),
                            cookie.getIsSecure()));
    }

    return result;
View Full Code Here

    public void addCookie(Cookie cookie) {
      // TODO: Numeric overflow
      if (cookie.getExpiry() == null) {
        cookie =
            new Cookie(cookie.getName(), cookie.getValue(), cookie.getDomain(), cookie.getPath(),
                       new Date(new Date().getTime() + (10 * 365 * 24 * 60 * 60 * 1000)), false);
      }

      debugger.executeJavascript("document.cookie='" + cookie.toString() + "'", false);
    }
View Full Code Here

      debugger.executeJavascript("document.cookie='" + cookie.toString() + "'", false);
    }

    public void deleteCookieNamed(String name) {
      Cookie cookie = getCookieNamed(name);
      if (cookie != null) {
        deleteCookie(cookie);
      }
    }
View Full Code Here

import org.openqa.selenium.Cookie;

public class DeleteCookie implements StepType {
  @Override
  public boolean run(TestRun ctx) {
    Cookie c = ctx.driver().manage().getCookieNamed(ctx.string("name"));
    if (c != null) {
      ctx.driver().manage().deleteCookie(c);
    }
    return true;
  }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.Cookie

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.