package org.jeecg.modules.ctop.job;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.GeckoDriverService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.io.File;
import java.util.concurrent.TimeUnit;

/**
 * @author jeecg-boot
 */
public class TestJob implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        System.setProperty("webdriver.gecko.driver", "/usr/lib/geckodriver");
        GeckoDriverService service = new GeckoDriverService.Builder().usingDriverExecutable(new File("/usr/lib/geckodriver")).usingAnyFreePort().build();
        FirefoxOptions options = new FirefoxOptions();
        options.addArguments("--headless");
        options.addArguments("--incognito");
        options.addArguments("--no-sandbox");
        options.addArguments("--disable-gpu");
        options.addArguments("--window-size=1290,1080");
        WebDriver driver = new FirefoxDriver(options);
        try {
            driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
            driver.manage().timeouts().setScriptTimeout(5, TimeUnit.SECONDS);
            driver.get("http://b.e.kuaishou.com");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            driver.quit();
            service.stop();
        }


    }
}
