package cz.moneta.test.dsl.ufo.operations.ufoOperations;

import cz.moneta.test.dsl.ufo.operations.client.clientDetail.STS701_S002_ClientDetailPage;
import cz.moneta.test.dsl.ufo.operations.shared.SharedElements;
import cz.moneta.test.dsl.ufo.operations.shared.topmenu.XXX701_SharedTopMenu;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.*;
import org.junit.jupiter.api.Assertions;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

import static cz.moneta.test.dsl.ufo.operations.shared.SharedElements.LOAD_IMG_DIV_CLASS;
import static cz.moneta.test.dsl.ufo.operations.ufoOperations.UKO720_S001_TaskPage.CATEGORY_COMBOBOX;

@Wait(CATEGORY_COMBOBOX)
@Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME)
public interface UKO720_S001_TaskPage extends WebFlow<UKO720_S001_TaskPage>, XXX701_SharedTopMenu, StoreAccessor {

    String ID_OBJECT_IN_TASK_KEY = "ID_OBJECT_IN_TASK";

    String TASK_ID_KEY = "TASKID";
    String TASK_LIST_XPATH = "//button[contains(@title, 'UKO701_S001_I001 [UKO720_S001_I001]')]";
    String CATEGORY_COMBOBOX = "UKO720_S001_C008";
    String SUBCATEGORIES_COMBOBOX = "UKO720_S001_C022";
    String REPORTER_TEAM_COMBOBOX = "UKO720_S001_C018";
    String BIRTH_NUMBER_IN_TASK = "UKO720_S001_E013";
    String CLIENT_DETAIL_INFO_IMG = "UKO720_S001_P002";
    String ID_OBJECT_IN_TASK_BUTTON = "UKO720_S001_E012";
    String ID_OM_IN_TASK_BUTTON = "UKO720_S001_E049";
    String ID_OBJECT_IN_TASK_XPATH = "//input[@id='UKO720_S001_E012']/following-sibling::input";
    String ID_OBJECT_DETAIL_INFO_IMG = "UKO720_S001_P021";
    String TASK_TYPE_COMBOBOX = "UKO720_S001_C007";
    String REQUEST_REASON_FIELD = "UKO720_S001_M002";
    String ASSIGN_BUTTON = "UKO720_S001_B010";
    String DESCRIPTION_FIELD = "UKO720_S001_M001";
    String ADD_NOTE_BUTTON = "UKO720_S001_B008";
    String FIRST_NOTE_TEXT_XPATH = "//table[@id='UKO720_S001_G008_UfoTable']/tbody//td[2]";
    String NOTE_WINDOW = "UKO720_S001_M006";
    String TASK_TREE_BUTTON_XPATH = "//button[(@title='UKO720_S001_I007 [UKO720_S001_I007]')]";
    String CANCELLATION_BUTTON = "UKO720_S001_B019";
    String CANCELLATION_REASON = "UKO720_S001_M006";

    String OK_BUTTON = "UKO720_S001_B007";
    String SPECIFIC_ATTRIBUTES = "UKO720_S001_H007_1";
    String CREATE_SUBTASK_BUTTON = "UKO720_S001_B020";
    String SOLUTION_BUTTON = "//button[@title='UKO720_S001_I008 [UKO720_S001_I008]']";
    String TASK_TYPE_SUBTASK_RADIO = "UKO720_S001_R005_subTask";
    String TREE_TABLE = "UKO720_S001_T001";
    String SOLVE_BUTTON = "UKO720_S001_B035";
    String FINISH_BUTTON = "UKO720_S001_B016";
    String SOLVE_TEXT_INPUT_XPATH = "//div[@id='UKO720_S001_X070']//textarea";
    String SAVE_BUTTON = "UKO720_S001_B014";
    String DELEGATE_BUTTON = "UKO720_S001_B024";
    String RETURN_BUTTON = "UKO720_S001_B021";
    String PDF_IMG = "UKO720_S001_P014";
    String ADD_ATTACHMENT_BUTTON = "UKO720_S001_B017";
    String FILE_UPLOAD_INPUT = "gwt-FileUpload";
    String FILE_TITLE_INPUT = "IPP701_S001_E001";
    String DOCUMENT_TYPE_SELECT = "IPP701_S001_C001";
    String SAVE_ATTACHMENT_BUTTON = "IPP701_S001_B001";
    String FIRST_ATTACHMENT_TITLE_DIV = "UKO720_S001_L123-1";
    String ID_TASK_INPUT = "UKO720_S001_E014";
    String CONNECT_TASKS_BUTTON = "UKO720_S001_B031";
    String SELECTION_ATTACHMENT = "ufo-et-UKO720_S001_F006_row_1_sel";
    String HISTORY_BUTTON = "//button[@title='UKO720_S001_I006 [UKO720_S001_I006]']";
    String TASK_CHANGE_CHECKBOX = "UKO720_S001_H003_1";
    String REASON_CHANGE = "UKO720_S001_M006";
    String FIRST_ATTACHMENT_DOWNLOAD_IMG = "UKO720_S001_P028-1";
    String FIRST_ATTACHMENT_DETAIL_IMG = "UKO720_S001_P018-1";
    String SOLVE_TAB_XPATH = "//button[text()='Řešení']";
    String ATTACHMENT_DETAIL_IMG = "UKO720_S001_O001";
    String LIST_OF_TASKS_XPATH = "//button[contains(@title, 'UKO720_S001_I001')]";
    String PREFERRED_CANAL_COMBOBOX = "UKO720_S001_C027";
    String SOLVING_GROUP_COMBOBOX = "UKO720_S001_C013";
    String SOLVER_COMBOBOX = "UKO720_S001_C009";
    String BUSINESS_COMBOBOX = "UKO720_S001_C012";
    String ID_TYPE_COMBOBOX = "UKO720_S001_C010";
    String NAME_OF_TASK_TEXTBOX = "UKO720_S001_E008";
    String CANAL_OF_TASK_COMBOBOX = "UKO720_S001_C023";
    String CLIENTS_EMAIL_TEXTBOX = "UKO720_S001_E029";
    String ID_OF_TASK = "UKO720_S001_L085";
    String TASK_PDF = "regression/ufo/task_document.pdf";
    String FIRST_DATE_IN_LIST_OF_NOTES_XPATH = "//table[@id='UKO720_S001_G008_UfoTable']/tbody/tr[1]/td[1]";
    String FIRST_DATE_IN_LIST_OF_ATTACHMENTS = "UKO720_S001_L122-1";
    String FIRST_DATE_IN_HISTORY = "UKO720_S001_L105-1";
    String FIRST_STATE_IN_HISTORY = "UKO720_S001_L106-1";
    String FIRST_SOLVER_IN_HISTORY = "UKO720_S001_L108-1";
    String FIRST_SOLVING_GROUP_IN_HISTORY = "UKO720_S001_L109-1";
    String FIRST_USER_IN_HISTORY = "UKO720_S001_L110-1";
    String NUMBER_OF_CARD_ACCOUNT_CREDIT_TEXTDIV = "UKO720_S001_E031";
    String ID_OF_CLIENT = "UKO720_S001_E011";
    String CLIENT_COMBOBOX = "UKO720_S001_C025";
    String NAME_OF_CLIENT_OR_BUSINESS = "UKO720_S001_E026";
    String UPDATE_BUTTON = "UKO720_S001_B030";
    String CHOOSE_ACTION_COMBOBOX = "UKO720_S001_C011";

    @Click(value = TASK_LIST_XPATH, by = Lookup.XPATH, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME))
    UKO720_S001_TaskList clickTaskList();

    @Wait(value = OK_BUTTON, until = Until.CLICKABLE)
    @Click(value = OK_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME))
    UKO720_S001_TaskPage clickOkButton();

    @Click(OK_BUTTON)
    UKO720_S001_TaskList clickOkCancellation();

    @Wait(value = ASSIGN_BUTTON, until = Until.VISIBLE, explicitWaitSeconds = 3)
    @Click(value = ASSIGN_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME))
    UKO720_S001_TaskPage_Transitions clickAssign();

    @Wait(DESCRIPTION_FIELD)
    @TypeInto(value = DESCRIPTION_FIELD, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME))
    UKO720_S001_TaskPage fillDescription(String description);

    @Wait(value = OK_BUTTON, until = Until.VISIBLE)
    @TypeInto(CANCELLATION_REASON)
    UKO720_S001_TaskPage fillCancellationReason(String reason);

    @Wait(value = NOTE_WINDOW, until = Until.GONE)
    @Click(value = CANCELLATION_BUTTON, andWait = @Wait(explicitWaitSeconds = 5))
    UKO720_S001_TaskPage clickCancellation();

    @Click(value = TASK_TREE_BUTTON_XPATH, by = Lookup.XPATH)
    UKO720_S001_TaskPage clickTaskTree();

    @Click(value = SPECIFIC_ATTRIBUTES)
    UKO720_S001_TaskPage clickSpecificAttributes();

    @Click(value = CREATE_SUBTASK_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME))
    UKO720_S001_TaskPage createSubtask();

    @Click(value = SOLUTION_BUTTON, by = Lookup.XPATH)
    UKO720_S001_TaskPage clickSolution();

    @Click(value = TASK_TYPE_SUBTASK_RADIO)
    UKO720_S001_TaskPage clickTaskTypeSubtask();

    @Wait(value = NOTE_WINDOW, until = Until.VISIBLE)
    @TypeInto(NOTE_WINDOW)
    UKO720_S001_TaskPage fillNote(String note);

    @Wait(value = REQUEST_REASON_FIELD, until = Until.VISIBLE)
    @TypeInto(value = REQUEST_REASON_FIELD, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME))
    UKO720_S001_TaskPage fillRequestReason(String reason);

    @Select(value = TASK_TYPE_COMBOBOX, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME))
    UKO720_S001_TaskPage selectTaskType(String taskType);

    @Wait(value = BIRTH_NUMBER_IN_TASK, until = Until.VISIBLE)
    @TypeInto(value = BIRTH_NUMBER_IN_TASK, clear = true, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME))
    UKO720_S001_TaskPage fillBirthNumberInTask(String birthNumber);

    @CustomAction
    default STS701_S002_ClientDetailPage clickClientDetailInfo() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.click(() -> CLIENT_DETAIL_INFO_IMG, Lookup.ID);
        endpoint.switchToOtherWindow(21, 2);
        return null;
    }

    @Wait(value = ID_OBJECT_IN_TASK_BUTTON, until = Until.VISIBLE)
    @TypeInto(value = ID_OBJECT_IN_TASK_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME))
    UKO720_S001_TaskPage fillIdObjectInTask(String id);

    @Wait(value = ID_OM_IN_TASK_BUTTON, until = Until.VISIBLE)
    @TypeInto(value = ID_OM_IN_TASK_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME))
    UKO720_S001_TaskPage fillIdOmInTask(String id);

    @CustomAction
    default UKO720_S001_TaskPage storeIdObject() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        String objectId = endpoint.getAttribute(ID_OBJECT_IN_TASK_XPATH, Lookup.XPATH, "value");
        store(ID_OBJECT_IN_TASK_KEY, objectId);
        return null;
    }

    @CustomAction
    default STS701_S002_ClientDetailPage clickIdObjectDetailInfo() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.click(() -> ID_OBJECT_DETAIL_INFO_IMG, Lookup.ID);
        endpoint.switchToOtherWindow(2, 2);
        return null;
    }

    @Wait(value = CATEGORY_COMBOBOX, until = Until.VISIBLE)
    @Select(value = CATEGORY_COMBOBOX, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME))
    UKO720_S001_TaskPage selectTaskCategory(String category);

    @Wait(value = SUBCATEGORIES_COMBOBOX, until = Until.VISIBLE)
    @Select(value = SUBCATEGORIES_COMBOBOX, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME))
    UKO720_S001_TaskPage selectSubcategories(String subcategories);

    @Wait(value = REPORTER_TEAM_COMBOBOX, until = Until.VISIBLE)
    @Select(value = REPORTER_TEAM_COMBOBOX, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME))
    UKO720_S001_TaskPage selectReporterTeam(String reporterTeam);

    @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME)
    @Wait(value = ADD_NOTE_BUTTON, until = Until.CLICKABLE)
    @Click(ADD_NOTE_BUTTON)
    UKO720_S001_TaskPage clickAddNote();

    @CheckElementContent(value = FIRST_NOTE_TEXT_XPATH, by = Lookup.XPATH)
    UKO720_S001_TaskPage checkFirstNoteText(String expectedText);

    @Wait(value = SOLVE_BUTTON, until = Until.CLICKABLE)
    @Click(value = SOLVE_BUTTON, andWait = @Wait(value = SharedElements.LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    UKO720_S001_TaskPage clickSolve();

    @CustomAction
    default UKO720_S001_TaskPage scrollToPageTop() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.scrollToPageTop();
        return null;
    }

    @CheckElementPresent(SOLVE_BUTTON)
    UKO720_S001_TaskPage checkSolveButtonPresent();

    @Click(value = FINISH_BUTTON, andWait = @Wait(value = SharedElements.LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    UKO720_S001_TaskPage clickFinishTask();

    @TypeInto(value = SOLVE_TEXT_INPUT_XPATH, by = Lookup.XPATH)
    UKO720_S001_TaskPage fillSolveText(String solveText);

    @TypeInto(value = ID_TASK_INPUT)
    UKO720_S001_TaskPage fillIdTaskConnect(String id);

    @Click(value = CONNECT_TASKS_BUTTON)
    UKO720_S001_TaskPage clickConnectTasks();

    @Click(value = OK_BUTTON, andWait = @Wait(value = SharedElements.LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    UKO720_S001_TaskList clickFinishOK();

    @Wait(value = SAVE_BUTTON, until = Until.CLICKABLE)
    @Click(value = SAVE_BUTTON, andWait = @Wait(value = SharedElements.LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    UKO720_S001_TaskPage clickSaveTask();

    @Wait(DELEGATE_BUTTON)
    @Click(value = DELEGATE_BUTTON, andWait = @Wait(value = SharedElements.LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    UKO720_S001_TaskList clickDelegateTask();

    @Click(value = RETURN_BUTTON, andWait = @Wait(value = SharedElements.LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    UKO720_S001_TaskPage clickReturnTask();

    @CustomAction
    default UKO720_S001_TaskPage clickFileDownload(String downloadButton) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.waitForElementsToLoad(5, Until.CLICKABLE, downloadButton);
        endpoint.click(() -> downloadButton);
        if (endpoint.isAlertPresent(1))
            endpoint.acceptAlert(1);
        endpoint.waitForElementsToLoad(30, Lookup.CLASSNAME, Until.GONE, SharedElements.LOAD_IMG_DIV_CLASS);
        return null;
    }

    @Click(ADD_ATTACHMENT_BUTTON)
    UKO720_S001_TaskPage clickAddAttachment();

    @TypeInto(value = FILE_UPLOAD_INPUT, by = Lookup.CLASSNAME, andWait = @Wait(value = FILE_TITLE_INPUT, until = Until.VISIBLE, explicitWaitSeconds = 10))
    UKO720_S001_TaskPage fillFileUpload(String file);

    @TypeInto(value = FILE_TITLE_INPUT, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE, explicitWaitSeconds = 3))
    UKO720_S001_TaskPage fillFileTitle(String fileTitle);

    @Select(value = DOCUMENT_TYPE_SELECT, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    UKO720_S001_TaskPage selectDocumentType(String documentType);

    @Click(value = SAVE_ATTACHMENT_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    UKO720_S001_TaskPage clickSaveAttachment();

    @Wait(value = FIRST_ATTACHMENT_TITLE_DIV, until = Until.VISIBLE)
    @CheckElementContent(FIRST_ATTACHMENT_TITLE_DIV)
    UKO720_S001_TaskPage checkTitleOfFirstAttachment(String expectedTitle);

    @Click(value = SELECTION_ATTACHMENT)
    UKO720_S001_TaskPage clickFirstAttachment();

    @Click(value = HISTORY_BUTTON, by = Lookup.XPATH)
    UKO720_S001_TaskPage clickHistory();

    @Wait(value = TASK_CHANGE_CHECKBOX, until = Until.CLICKABLE)
    @Click(value = TASK_CHANGE_CHECKBOX)
    UKO720_S001_TaskPage clickTaskChangeCheckbox();

    @Wait(value = TASK_CHANGE_CHECKBOX, until = Until.CLICKABLE)
    @Click(value = TASK_CHANGE_CHECKBOX)
    @AcceptAlert(waitSecondsForAlert = 5)
    UKO720_S001_TaskPage clickTaskChangeCheckboxAndAcceptAlert();

    @TypeInto(value = REASON_CHANGE)
    UKO720_S001_TaskPage fillReason(String reasonText);

    @Click(value = FIRST_ATTACHMENT_DETAIL_IMG, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    UKO720_S001_TaskPage clickFirstAttachmentDetail();

    @Wait(ATTACHMENT_DETAIL_IMG)
    UKO720_S001_TaskPage waitForAttachmentDetail();

    @Click(value = SOLVE_TAB_XPATH, by = Lookup.XPATH, andWait = @Wait(value = ADD_ATTACHMENT_BUTTON, until = Until.VISIBLE))
    UKO720_S001_TaskPage clickSolveTab();

    @Wait(value = LIST_OF_TASKS_XPATH, until = Until.VISIBLE, by = Lookup.XPATH)
    @Click(value = LIST_OF_TASKS_XPATH, by = Lookup.XPATH, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    UKO720_S001_TaskList clickListOfTasks();

    @Wait(value = ID_OF_TASK, until = Until.VISIBLE)
    @CheckElementPresent(ID_OF_TASK)
    UKO720_S001_TaskPage checkPresenceOfTaskId();

    @CheckElementPresent(DELEGATE_BUTTON)
    UKO720_S001_TaskPage checkDelegateTaskBtn();

    @CheckElementPresent(UPDATE_BUTTON)
    UKO720_S001_TaskPage checkUpdateBtn();

    @CustomAction
    default UKO720_S001_TaskPage checkDelegateTaskBtnNotEnabled() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        Assertions.assertFalse(endpoint.isElementEnabled(DELEGATE_BUTTON), "The delegate task button " + DELEGATE_BUTTON + " is enabled");
        return null;
    }

    @Wait(value = PREFERRED_CANAL_COMBOBOX, until = Until.VISIBLE)
    @Select(PREFERRED_CANAL_COMBOBOX)
    UKO720_S001_TaskPage selectPreferredCanal(String preferredCanal);

    @CustomAction
    default UKO720_S001_TaskPage checkComboboxValue(String comboboxName, String expectedValue) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        String actualValue = endpoint.getAttribute(comboboxName, "value");
        Assertions.assertEquals(expectedValue, actualValue, "Expected value for " + comboboxName + ": " + expectedValue + ", but found: " + actualValue);
        return null;
    }

    @CustomAction
    default UKO720_S001_TaskPage findUserAndSelectSolver() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.waitForElementsToLoad(5, SOLVER_COMBOBOX);
        String userSSO = endpoint.getAttribute(SSO_OF_LOGGED_USER, Lookup.XPATH, "value");
        endpoint.selectByValue(SOLVER_COMBOBOX, userSSO);
        return null;
    }

    @CheckElementContent(BUSINESS_COMBOBOX)
    UKO720_S001_TaskPage checkBusiness(String business);

    @CheckElementContent(CANAL_OF_TASK_COMBOBOX)
    UKO720_S001_TaskPage checkCanalOfTask(String canalOfTask);

    @CustomAction
    default UKO720_S001_TaskPage checkRcClientAndType(String expectedBirthNumber) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.waitForElementsToLoad(5, BIRTH_NUMBER_IN_TASK, ID_TYPE_COMBOBOX);
        Assertions.assertEquals(expectedBirthNumber, endpoint.getAttribute(BIRTH_NUMBER_IN_TASK, "value"));
        Assertions.assertEquals("1", endpoint.getAttribute(ID_TYPE_COMBOBOX, "value"));
        return null;
    }

    @CustomAction
    default UKO720_S001_TaskPage checkNameOfTask(String expectedName) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        Assertions.assertEquals(expectedName, endpoint.getAttribute(NAME_OF_TASK_TEXTBOX, "value"));
        return null;
    }

    @TypeInto(value = NAME_OF_TASK_TEXTBOX, clear = true)
    UKO720_S001_TaskPage fillNameOfTask(String name);

    @CustomAction
    default UKO720_S001_TaskPage checkDescriptionSolverEmailAndSolver(String expectedBirthNumber, String expectedEmail) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.waitForElementsToLoad(5, BIRTH_NUMBER_IN_TASK, SOLVER_COMBOBOX, CLIENTS_EMAIL_TEXTBOX, PREFERRED_CANAL_COMBOBOX);
        String ssoOfUser = endpoint.getAttribute(SSO_OF_LOGGED_USER, Lookup.XPATH, "value");
        Assertions.assertEquals(expectedBirthNumber, endpoint.getAttribute(BIRTH_NUMBER_IN_TASK, "value"));
        Assertions.assertEquals(ssoOfUser, endpoint.getAttribute(SOLVER_COMBOBOX, "value"));
        Assertions.assertEquals(expectedEmail, endpoint.getAttribute(CLIENTS_EMAIL_TEXTBOX, "value"));
        Assertions.assertEquals("email", endpoint.getAttribute(PREFERRED_CANAL_COMBOBOX, "value"));
        return null;
    }

    @Click(FINISH_BUTTON)
    @AcceptAlert(waitSecondsForAlert = 10, expectedAlertText = "Není vytvořena odpověď pro klienta, opravdu chcete dokončit úkol?")
    UKO720_S001_TaskPage clickFinishAndAcceptAnswerAlert();

    @CustomAction
    default UKO720_S001_TaskPage checkStatusLabelContent(String expectedStatusText) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        String idOfTask = endpoint.getText(ID_OF_TASK);
        String fullText = endpoint.getText(STATUS_LABEL);
        String textWithoutTime = fullText.replaceFirst("^\\d{2}:\\d{2}:\\d{2}", "");
        Assertions.assertTrue(textWithoutTime.contains(idOfTask + expectedStatusText));
        return null;
    }

    @Wait(value = ID_OF_TASK, until = Until.VISIBLE)
    @StoreElementContent(storeKey = TASK_ID_KEY, value = ID_OF_TASK)
    UKO720_S001_TaskPage storeIdOfTask();

    // explicitWait waits for the JavaScript (onexit) function of UFO OPS, which blocks saving the email.
    @Wait(CLIENTS_EMAIL_TEXTBOX)
    @TypeInto(value = CLIENTS_EMAIL_TEXTBOX, clear = true, andWait = @Wait(explicitWaitSeconds = 1))
    UKO720_S001_TaskPage typeIntoClientsEmail(String email);

    @CustomAction
    default UKO720_S001_TaskPage checkDateInLabel(String elementWithDate, Lookup lookup) {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        LocalDate date = LocalDate.parse(endpoint.getText(elementWithDate, lookup), DateTimeFormatter.ofPattern("d.M.yyyy H:mm:ss"));
        Assertions.assertEquals(date, LocalDate.now(), "Times are not the same");
        return null;
    }

    @Wait(FIRST_DATE_IN_HISTORY)
    @CheckElementsPresent(value = {
            @CheckElementPresent(FIRST_DATE_IN_HISTORY),
            @CheckElementPresent(FIRST_STATE_IN_HISTORY),
            @CheckElementPresent(FIRST_SOLVER_IN_HISTORY),
            @CheckElementPresent(FIRST_SOLVING_GROUP_IN_HISTORY),
            @CheckElementPresent(FIRST_USER_IN_HISTORY)})
    UKO720_S001_TaskPage checkHistoryOfTask();

    @TypeInto(ID_OF_CLIENT)
    UKO720_S001_TaskPage fillIdOfClient(String cif);

    @Wait(NUMBER_OF_CARD_ACCOUNT_CREDIT_TEXTDIV)
    @TypeInto(value = NUMBER_OF_CARD_ACCOUNT_CREDIT_TEXTDIV, clear = true, andWait = @Wait(explicitWaitSeconds = 1))
    UKO720_S001_TaskPage fillNumberOfCard(String number);

    @Select(CLIENT_COMBOBOX)
    UKO720_S001_TaskPage selectClient(String client);

    @TypeInto(value = NAME_OF_CLIENT_OR_BUSINESS, andWait = @Wait(explicitWaitSeconds = 1))
    UKO720_S001_TaskPage fillClientOrBusinessName(String name);

    @Wait(value = CHOOSE_ACTION_COMBOBOX, until = Until.VISIBLE)
    @Select(CHOOSE_ACTION_COMBOBOX)
    UKO720_S001_TaskDetail selectChooseAction(String action);
}
