All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sitoolkit.wt.infra.selenium.WebDriverCloser Maven / Gradle / Ivy

There is a newer version: 2.3
Show newest version
package org.sitoolkit.wt.infra.selenium;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PreDestroy;
import javax.annotation.Resource;

import org.openqa.selenium.WebDriver;
import org.sitoolkit.wt.infra.PropertyManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class WebDriverCloser {

    private static final Logger LOG = LoggerFactory.getLogger(WebDriverCloser.class);

    private List driverList = new ArrayList<>();

    @Resource
    PropertyManager pm;

    public void register(WebDriver driver) {
        driverList.add(driver);
    }

    /**
    *
    */
    @PreDestroy
    public void preDestroy() {
        if (pm.isRemoteDriver()) {
            return;
        }

        driverList.parallelStream().forEach(driver -> {
            LOG.debug("WebDriverを停止します {}", driver);
            try {
                driver.quit();
            } catch (Exception e) {
                LOG.trace(e.getMessage());
            }
        });
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy