Example usage for org.openqa.selenium Cookie.Builder domain

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

Introduction

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

Prototype

String domain

To view the source code for org.openqa.selenium Cookie.Builder domain.

Click Source Link

Usage

From source file:org.fitting.selenium.fixture.CookieFixture.java

License:Apache License

/**
 * Adds a cookie with the given data./*from w w  w.j a v a 2 s.co m*/
 *
 * @param driver The web driver.
 * @param name   The name of the cookie.
 * @param value  The value of the cookie.
 * @param path   The path to set the cookie.
 * @param domain The domain.
 */
private void addCookie(final WebDriver driver, final String name, final String value, final String path,
        final String domain) {
    handleCookie(domain, new CookieCallback() {
        @Override
        public void execute() {
            final Cookie.Builder builder = new Cookie.Builder(name, value);
            if (isNotEmpty(path)) {
                builder.path(path);
            }
            if (isNotEmpty(domain)) {
                builder.domain(getStrippedDomain(domain));
            }

            driver.manage().addCookie(builder.build());
        }
    });
}