Example usage for org.openqa.selenium Cookie Cookie

List of usage examples for org.openqa.selenium Cookie Cookie

Introduction

In this page you can find the example usage for org.openqa.selenium Cookie Cookie.

Prototype

public Cookie(String name, String value) 

Source Link

Document

Create a cookie for the default path with the given name and value with no expiry set.

Usage

From source file:plugin.shiro.authc.RememberMeTestCase.java

License:Open Source License

@Test
@InSequence(1)//from w w w  .jav a 2 s.  c om
@RunAsClient
public void testAfterLogin() throws Exception {
    driver.get(deploymentURL.toString());
    waitForPresent(driver, "root logged");

    String rememberToken = driver.manage().getCookieNamed("rememberMe").getValue();

    driver.manage().deleteAllCookies();

    driver.get(deploymentURL.toString());
    WebElement username = driver.findElement(By.id("uname"));
    assertNotNull(username);

    driver.manage().addCookie(new Cookie("rememberMe", rememberToken));

    driver.get(deploymentURL.toString());
    waitForPresent(driver, "root logged");
}

From source file:ru.stqa.selenium.decorated.DecoratedOptionsTest.java

License:Apache License

@Test
void testAddCookie() {
    verifyFunction($ -> $.addCookie(new Cookie("name", "value")));
}

From source file:ru.stqa.selenium.decorated.DecoratedOptionsTest.java

License:Apache License

@Test
void testDeleteCookie() {
    verifyFunction($ -> $.deleteCookie(new Cookie("name", "value")));
}

From source file:ru.stqa.selenium.decorated.DecoratedOptionsTest.java

License:Apache License

@Test
void testGetCookies() {
    Set<Cookie> cookies = new HashSet<>();
    cookies.add(new Cookie("name", "value"));
    verifyFunction(WebDriver.Options::getCookies, cookies);
}

From source file:ru.stqa.selenium.decorated.DecoratedOptionsTest.java

License:Apache License

@Test
void testGetCookieNamed() {
    verifyFunction($ -> $.getCookieNamed("test"), new Cookie("name", "value"));
}

From source file:ru.stqa.selenium.decorated.events.WebDriverListenerTest.java

License:Apache License

@Test
void canFireEventForAddCookie() {
    Fixture fixture = new Fixture();

    final WebDriver.Options options = mock(WebDriver.Options.class);
    Cookie cookie = new Cookie("name", "value");

    when(fixture.mockedDriver.manage()).thenReturn(options);

    fixture.driver.manage().addCookie(cookie);

    verify(fixture.mockedDriver, times(1)).manage();
    verifyNoMoreInteractions(fixture.mockedDriver);
    verify(options, times(1)).addCookie(cookie);
    verifyNoMoreInteractions(options);//from   w  w w  . ja va  2  s  .  com
    verify(fixture.listener, times(1)).beforeAddCookie(options, cookie);
    verify(fixture.listener, times(1)).afterAddCookie(options, cookie);
    verifyNoMoreInteractions(fixture.listener);
}

From source file:ru.stqa.selenium.decorated.events.WebDriverListenerTest.java

License:Apache License

@Test
void canFireEventForDeleteCookie() {
    Fixture fixture = new Fixture();

    final WebDriver.Options options = mock(WebDriver.Options.class);
    Cookie cookie = new Cookie("name", "value");

    when(fixture.mockedDriver.manage()).thenReturn(options);

    fixture.driver.manage().deleteCookie(cookie);

    verify(fixture.mockedDriver, times(1)).manage();
    verifyNoMoreInteractions(fixture.mockedDriver);
    verify(options, times(1)).deleteCookie(cookie);
    verifyNoMoreInteractions(options);/*  w w w  . j a  va  2s.  c o m*/
    verify(fixture.listener, times(1)).beforeDeleteCookie(options, cookie);
    verify(fixture.listener, times(1)).afterDeleteCookie(options, cookie);
    verifyNoMoreInteractions(fixture.listener);
}

From source file:ru.stqa.selenium.decorated.events.WebDriverListenerTest.java

License:Apache License

@Test
void canFireEventForGetCookies() {
    Fixture fixture = new Fixture();

    final WebDriver.Options options = mock(WebDriver.Options.class);
    Cookie cookie = new Cookie("name", "value");
    Set<Cookie> cookies = new HashSet<>();
    cookies.add(cookie);/*from  w  w  w.j  av a2s  .  co m*/

    when(fixture.mockedDriver.manage()).thenReturn(options);
    when(options.getCookies()).thenReturn(cookies);

    assertEquals(fixture.driver.manage().getCookies(), cookies);

    verify(fixture.mockedDriver, times(1)).manage();
    verifyNoMoreInteractions(fixture.mockedDriver);
    verify(options, times(1)).getCookies();
    verifyNoMoreInteractions(options);
    verify(fixture.listener, times(1)).beforeGetCookies(options);
    verify(fixture.listener, times(1)).afterGetCookies(cookies, options);
    verifyNoMoreInteractions(fixture.listener);
}

From source file:ru.stqa.selenium.decorated.events.WebDriverListenerTest.java

License:Apache License

@Test
void canFireEventForGetCookieNamed() {
    Fixture fixture = new Fixture();

    final WebDriver.Options options = mock(WebDriver.Options.class);
    Cookie cookie = new Cookie("name", "value");

    when(fixture.mockedDriver.manage()).thenReturn(options);
    when(options.getCookieNamed("test")).thenReturn(cookie);

    assertEquals(fixture.driver.manage().getCookieNamed("test"), cookie);

    verify(fixture.mockedDriver, times(1)).manage();
    verifyNoMoreInteractions(fixture.mockedDriver);
    verify(options, times(1)).getCookieNamed("test");
    verifyNoMoreInteractions(options);/*from   w w w .  j  av a 2 s .co m*/
    verify(fixture.listener, times(1)).beforeGetCookieNamed(options, "test");
    verify(fixture.listener, times(1)).afterGetCookieNamed(cookie, options, "test");
    verifyNoMoreInteractions(fixture.listener);
}