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

import cz.moneta.test.dsl.ufo.banka.pages.cards.debit.HPO009_S001_DebitCardDetailPage;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.CustomAction;
import cz.moneta.test.harness.support.web.Lookup;
import cz.moneta.test.harness.support.web.Wait;
import cz.moneta.test.harness.support.web.WebFlow;

import static cz.moneta.test.dsl.ufo.banka.pages.main.HLE001_S009_CardSearchedPage.HLE001_S009_PAGE_LABEL_XPATH;

@Wait(value = HLE001_S009_PAGE_LABEL_XPATH, waitSecondsForElement = 120, by = Lookup.XPATH)
public interface HLE001_S009_CardSearchedPage extends WebFlow<HLE001_S009_CardSearchedPage>, StoreAccessor {
    String HLE001_S009_PAGE_LABEL_XPATH = "//div[text()='HLE001_S009']";
    String OK_BUTTON = "HLE001_S009_B002";

    @CustomAction
    default HPO009_S001_DebitCardDetailPage clickOkButtonAndCloseAlertIfVisible() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.click(() -> OK_BUTTON);
        if (endpoint.isAlertPresent(3)) {
            endpoint.dismissAlert(1);
        }
        return null;
    }
}
