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

com.github.nscuro.wdm.factory.WebDriverFactoryConfig Maven / Gradle / Ivy

There is a newer version: 0.3.0
Show newest version
package com.github.nscuro.wdm.factory;

import com.github.nscuro.wdm.Browser;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * Programmatic configuration for {@link WebDriverFactory}.
 */
@Data
public final class WebDriverFactoryConfig {

    private Map binaryVersions;

    public WebDriverFactoryConfig() {
        binaryVersions = new HashMap<>();
    }

    /**
     * Specify which driver binary version to download for a given {@link Browser}.
     *
     * @param browser The {@link Browser} this preference should apply for
     * @param version The desired version
     */
    public void setBinaryVersionForBrowser(final Browser browser, final String version) {
        binaryVersions.put(browser, version);
    }

    /**
     * Get the desired binary version for a given {@link Browser}.
     *
     * @param browser The {@link Browser} to get the binary version for
     * @return The desired version or {@link Optional#empty()}, in which case the latest
     *         version should be used
     */
    public Optional getBinaryVersionForBrowser(final Browser browser) {
        return binaryVersions.entrySet().stream()
                .filter(entry -> entry.getKey() == browser)
                .map(Map.Entry::getValue)
                .findAny();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy