package zacksolutions;

import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.reporter.ExtentReporter;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;

import com.aventstack.extentreports.reporter.ExtentSparkReporter;
import org.testng.annotations.Test;
public class ExtendReports {
  ExtentReports extent;
  WebDriver driver;

  @BeforeTest
  public void ExtentConfig() {
    String path = System.getProperty("user.dir") + "/reports/index.html";
    ExtentSparkReporter spark = new ExtentSparkReporter(path);
    spark.config().setDocumentTitle("Tests Cases Extent Reports");
    spark.config().setReportName("Extent Reports");
    extent = new ExtentReports();
    extent.attachReporter(spark);
    extent.setSystemInfo("Tests Done by: ", "Zakaria");

    // Initialize WebDriver
    System.setProperty("webdriver.gecko.driver", "/home/ilyes/SeleniumPractice/testNG_FrameWork/drivers/geckodriver");
    driver = new FirefoxDriver();
  }

  @Test
  public void getTitle(){
    ExtentTest test = extent.createTest("TestTitle");
    String title = driver.getTitle();
    System.out.println(title);
    System.out.println("Page Title: " + title);
    test.fail("Test fail");
    test.addScreenCaptureFromBase64String("user.dir");
    extent.flush();
    driver.close();
  }
}
