package cz.moneta.test.dsl.ufo.banka.pages.insurance;

import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.ufo.banka.pages.insurance.StelaNnLifeInsurancePage.FIRSTNAME_INPUT;

@Wait(value = FIRSTNAME_INPUT, by = Lookup.XPATH, waitSecondsForElement = 50)
public interface StelaNnLifeInsurancePage extends WebFlow<StelaNnLifeInsurancePage>, StoreAccessor {
    String FIRSTNAME_INPUT = "//input[@id='first-name']";
    String LASTNAME_INPUT = "//input[@id='last-name']";
    String BIRTHDATE_INPUT = "//span[@id='birthdate']/input";
    String SEX_INPUT = "//div[contains(@class,'PersonalData-module_sex__')]//select";

    @CustomAction
    default StelaNnLifeInsurancePage storeNnInputValues() {
        UfoEndpoint e = getEndpoint(UfoEndpoint.class);
        store("NN_FIRSTNAME", e.getAttribute(FIRSTNAME_INPUT, Lookup.XPATH, "value"));
        store("NN_LASTNAME", e.getAttribute(LASTNAME_INPUT, Lookup.XPATH, "value"));
        store("NN_BIRTHDATE", e.getAttribute(BIRTHDATE_INPUT, Lookup.XPATH, "value"));
        store("NN_SEX", e.getAttribute(SEX_INPUT, Lookup.XPATH, "value"));
        return null;
    }
}