package org.getopentest.selenium;

import org.getopentest.annotations.TestActionClass;
import org.getopentest.selenium.core.SeleniumTestAction;
import org.openqa.selenium.Cookie;

@TestActionClass(description = "Adds a cookie.")

public class AddCookie extends SeleniumTestAction {

    @Override
    public void run() {
        super.run();

        String name = this.readStringArgument("name");
        String value = this.readStringArgument("value");
        String domain = this.readStringArgument("domain", null);
        String path = this.readStringArgument("path", null);
        Boolean isSecure = this.readBooleanArgument("isSecure", false);
        Boolean isHttpOnly = this.readBooleanArgument("isHttpOnly", false);

        Cookie cookie = new Cookie(name, value, domain, path, null, isSecure, isHttpOnly);
        driver.manage().addCookie(cookie);
    }
}
