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

aquality.selenium.configuration.TimeoutConfiguration Maven / Gradle / Ivy

There is a newer version: 4.9.0
Show newest version
package aquality.selenium.configuration;

import aquality.selenium.core.utilities.ISettingsFile;
import com.google.inject.Inject;

import java.time.Duration;

public class TimeoutConfiguration extends aquality.selenium.core.configurations.TimeoutConfiguration
        implements ITimeoutConfiguration {

    private final ISettingsFile settingsFile;
    private final Duration script;
    private final Duration pageLoad;

    @Inject
    public TimeoutConfiguration(ISettingsFile settingsFile) {
        super(settingsFile);
        this.settingsFile = settingsFile;
        script = getDurationFromSeconds(TIMEOUT.SCRIPT);
        pageLoad = getDurationFromSeconds(TIMEOUT.PAGE_LOAD);
    }

    private Duration getDurationFromSeconds(TIMEOUT timeout) {
        long seconds = Long.parseLong(settingsFile.getValue("/timeouts/" + timeout.getKey()).toString());
        return Duration.ofSeconds(seconds);
    }

    public Duration getScript() {
        return script;
    }

    public Duration getPageLoad() {
        return pageLoad;
    }

    private enum TIMEOUT {
        SCRIPT("timeoutScript"),
        PAGE_LOAD("timeoutPageLoad");

        private final String key;

        TIMEOUT(String key) {
            this.key = key;
        }

        private String getKey() {
            return key;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy