package com.intland.codebeamer.functionaltest.page.trackers;

import com.intland.codebeamer.functionaltest.page.BasePage;
import com.intland.codebeamer.functionaltest.page.common.EditorComponent;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.support.ui.ExpectedConditions;
import java.util.concurrent.TimeUnit;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.Wait;

/**
 * Copyright by Intland Software
 * <p>
 * All rights reserved.
 * <p>
 * This software is the confidential and proprietary information
 * of Intland Software. ("Confidential Information"). You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Intland.
 */
public class AddCommentDialog extends BasePage {

    public EditorComponent editorComponent = new EditorComponent();

    @Override
    public boolean isPageLoaded() throws UnsupportedOperationException {
        try {
            Wait().withTimeout(5, TimeUnit.SECONDS)
                    .ignoring(NoSuchElementException.class)
                    .until(ExpectedConditions.visibilityOf($("#addComment")));
        }catch(Exception e){
            return false;
        }
        return true;
    }

    public void clickOnSave() {
        $(By.xpath(".//input[@name='save']")).click();
    }

}
