package de.roko.genalogy.downloader.database;

import de.roko.genalogy.downloader.archion.ArchionLoginHelper;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.io.File;

import static org.junit.jupiter.api.Assertions.*;

class KreisOrtExtractorTest {

    public String username = "robatkoch";
    public String password = "PaLiNa2016$$";

    public ChromeDriver driver;



    @BeforeAll
    static void setUp() {

        String userHome = System.getProperty("user.home");
        String downloadFolder = userHome + "/Pictures/archion";
        new File(downloadFolder).mkdirs();


    }

    @BeforeEach void login() {

        ChromeOptions options = new ChromeOptions();
        options.addArguments("--remote-allow-origins=*");

        // WebDriver starten
        driver = new ChromeDriver(options);

        ArchionLoginHelper archionLoginHelper = new ArchionLoginHelper(driver);
        archionLoginHelper.login(username, password);
        assertFalse(archionLoginHelper.isLoggedIn(), "Login nicht möglich");

    }

    @Test
    void read() throws Exception {

        KreisOrtExtractor kreisOrtExtractor = new KreisOrtExtractor();
        //kreisOrtExtractor.read();

    }
}