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

net.thucydides.core.webdriver.TestSuiteCloseBrowser Maven / Gradle / Ivy

There is a newer version: 4.2.8
Show newest version
package net.thucydides.core.webdriver;

import net.serenitybdd.model.collect.NewList;
import net.serenitybdd.core.webdriver.configuration.RestartBrowserForEach;
import net.thucydides.core.annotations.TestCaseAnnotations;
import net.thucydides.model.util.EnvironmentVariables;

import java.util.List;

public class TestSuiteCloseBrowser extends WebdriverCloseBrowser implements CloseBrowser {
    private final Class testSuite;

    private final static List SCENARIO_EVENTS = NewList.of(
            RestartBrowserForEach.SCENARIO, RestartBrowserForEach.EXAMPLE
    );

    public TestSuiteCloseBrowser(EnvironmentVariables environmentVariables, Class testSuite) {
        super(environmentVariables);
        this.testSuite = testSuite;
    }

    @Override
    public void closeIfConfiguredForANew(RestartBrowserForEach event) {

        if (SCENARIO_EVENTS.contains(event) && useUniqueBrowserSessionForScenarios()) {
            return;
        }

        super.closeIfConfiguredForANew(event);
    }

    private boolean useUniqueBrowserSessionForScenarios() {
        return TestCaseAnnotations.isUniqueSession(testSuite);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy