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.Input;
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() {
        List<Input> inputs = Lists.newArrayList();
        inputs.add(new Input(null,null,null,"caozuoyuan"));
        inputs.add(new Input(null,null,null,"caozuoyuan123"));

        String url = "http://192.168.1.244:8080/person/#/login";
        Project project = new Project(
                null,
                null,
                "firefox",
                url,
                inputs
        );
        Report report = seleniumExecutor.execute(project);
        for (Measure measure : report.getMeasures()) {
            System.out.println(measure);
        }
    }
}
