package com.intland.codebeamer.functionaltest.page;

import com.codeborne.selenide.ElementsCollection;
import com.codeborne.selenide.SelenideElement;
import com.intland.codebeamer.functionaltest.helper.Helper;
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.$$;
import static com.codeborne.selenide.Selenide.Wait;

public class DocumentsPage extends BasePage{

    private SelenideElement documentTree = $(By.id("documentTree"));

    public void clickOnDocumentRoot() {
        $(By.linkText("Documents")).click();
    }

    public void clickOnFolder(String folderName) {
        $(By.linkText(folderName)).click();
    }

    public SelenideElement getDocumentTable() {
        return $(By.className("displaytag"));
    }


    public ElementsCollection getDocumentTreeItems(){
        Helper.openAllRootNodes(documentTree);
        return $$("li[role='treeitem'] a");
    }
}
