package Tests;

import Utility.ExcelUtils;
import Utility.KeywordUtils;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.testng.asserts.SoftAssert;

import java.util.concurrent.TimeUnit;


public class SendEmailTestClass {

    private WebDriver driver;
    private SoftAssert sa;
    private ExcelUtils excelUtils;
    private KeywordUtils keywordUtils;


    private String geckoDriverPath;
    private String excelPath;


    @BeforeClass
    public void beforeClass() throws Exception {
        geckoDriverPath = "C:\\Users\\lukas\\IdeaProjects\\BpSeznamEmail\\geckodriver.exe";
        System.setProperty("webdriver.gecko.driver", geckoDriverPath);
        excelPath = "C:\\Users\\lukas\\IdeaProjects\\BpSeznamEmail\\src\\main\\java\\DataEngine\\SendEmailTests.xlsx";

        excelUtils = new ExcelUtils();
        excelUtils.setExcelFile(excelPath);

        keywordUtils = new KeywordUtils(excelUtils);

    }


    @AfterMethod
    public void afterMethod() {
        driver.quit();
    }

    @BeforeMethod
    public void beforeMethod() throws Exception {
        sa = new SoftAssert();
        driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        keywordUtils.initPages(driver, sa);
    }


    @Test(priority = 1)
    public void SendEmailTCKeywords() throws Exception {
        keywordUtils.initTC("Send_Email");
        keywordUtils.performTest();
        sa.assertAll(); //This can't be in @AfterMethod because it's feature of testNG that if there is failure in @AfterMethod the test run is terminated
    }


}


