<commit_before>package com.codeborne.selenide.webdriver;

import com.codeborne.selenide.Selenide;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.internal.BuildInfo;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.awt.*;
import java.util.Arrays;
import java.util.logging.Logger;

import static com.codeborne.selenide.Configuration.*;
import static com.codeborne.selenide.WebDriverRunner.isChrome;
import static com.codeborne.selenide.WebDriverRunner.isHeadless;
import static com.codeborne.selenide.impl.Describe.describe;

public class WebDriverFactory {

  private static final Logger log = Logger.getLogger(WebDriverFactory.class.getName());

  public WebDriver createWebDriver(Proxy proxy) {
    log.config("Configuration.browser=" + browser);
    log.config("Configuration.browser.version=" + browserVersion);
    log.config("Configuration.remote=" + remote);
    log.config("Configuration.browserSize=" + browserSize);
    log.config("Configuration.startMaximized=" + startMaximized);

    final AbstractDriverFactory[] factories = new AbstractDriverFactory[]{
        new RemoteDriverFactory(),
        new ChromeDriverFactory(),
        new MarionetteDriverFactory(),
        new FirefoxDriverFactory(),
        new HtmlUnitDriverFactory(),
        new EdgeDriverFactory(),
        new InternetExplorerDriverFactory(),
        new PhantomJsDriverFactory(),
        new OperaDriverFactory(),
        new SafariDriverFactory(),
        new JBrowserDriverFactory(),
    };

    WebDriver webdriver = Arrays.stream(factories)
        .filter(AbstractDriverFactory::supports)
        .findAny()
        .map(driverFactory -> driverFactory.create(proxy))
        .orElseGet(() -> new DefaultDriverFactory().create(proxy));

    webdriver = adjustBrowserSize(webdriver);

    logBrowserVersion(webdriver);
    log.info("Selenide v. " + Selenide.class.getPackage().getImplementationVersion());
    logSeleniumInfo();<commit_msg>#606 refactoring: use List instead of array<commit_after>package com.codeborne.selenide.webdriver;

import com.codeborne.selenide.Selenide;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.internal.BuildInfo;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.awt.*;
import java.util.List;
import java.util.logging.Logger;

import static com.codeborne.selenide.Configuration.*;
import static com.codeborne.selenide.WebDriverRunner.isChrome;
import static com.codeborne.selenide.WebDriverRunner.isHeadless;
import static com.codeborne.selenide.impl.Describe.describe;
import static java.util.Arrays.asList;

public class WebDriverFactory {

  private static final Logger log = Logger.getLogger(WebDriverFactory.class.getName());

  public WebDriver createWebDriver(Proxy proxy) {
    log.config("Configuration.browser=" + browser);
    log.config("Configuration.browser.version=" + browserVersion);
    log.config("Configuration.remote=" + remote);
    log.config("Configuration.browserSize=" + browserSize);
    log.config("Configuration.startMaximized=" + startMaximized);

    final List<AbstractDriverFactory> factories = asList(
        new RemoteDriverFactory(),
        new ChromeDriverFactory(),
        new MarionetteDriverFactory(),
        new FirefoxDriverFactory(),
        new HtmlUnitDriverFactory(),
        new EdgeDriverFactory(),
        new InternetExplorerDriverFactory(),
        new PhantomJsDriverFactory(),
        new OperaDriverFactory(),
        new SafariDriverFactory(),
        new JBrowserDriverFactory()
    );

    WebDriver webdriver = factories.stream()
        .filter(AbstractDriverFactory::supports)
        .findAny()
        .map(driverFactory -> driverFactory.create(proxy))
        .orElseGet(() -> new DefaultDriverFactory().create(proxy));

    webdriver = adjustBrowserSize(webdriver);

    logBrowserVersion(webdriver);
    log.info("Selenide v. " + Selenide.class.getPackage().getImplementationVersion());
    logSeleniumInfo();
{'fraction_non_alphanumeric': 0.10952040085898354, 'fraction_numerical': 0.0007158196134574087, 'mean_word_length': 4.486910994764398, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3957157', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1138, 'n_words': 209}