package com.zjty.autotest;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.zjty.autotest.pojo.report.Measure;
import com.zjty.autotest.pojo.report.Report;
import com.zjty.autotest.pojo.test.Project;
import com.zjty.autotest.service.impl.SeleniumExecutor;
import com.zjty.autotest.util.WebDriverUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.logging.LogType;
import org.openqa.selenium.logging.LoggingPreferences;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.*;
import java.util.logging.Level;

@Slf4j
@SpringBootTest
class AutotestApplicationTests {

    @Autowired
    SeleniumExecutor seleniumExecutor;

    @Test
    public void execute() {
        Map<String, String> inputs = Maps.newHashMap();
        inputs.put("name", "root");
        inputs.put("password", "root");
        String url = "https://www.cnblogs.com/invoker-/";
        Project project = new Project(
                null,
                null,
                "firefox",
                url,
                Lists.newArrayList()
        );
        Report report = seleniumExecutor.execute(project);
        for (Measure measure : report.getMeasures()) {
            System.out.println(measure);
        }
    }
}
