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

com.testvagrant.optimus.core.web.FirefoxDriverManager Maven / Gradle / Ivy

Go to download

Optimus Lite API to manage test devices and create appium driver based on platform

There is a newer version: 0.1.7-beta
Show newest version
package com.testvagrant.optimus.core.web;

import com.testvagrant.optimus.core.parser.WebTestFeedParser;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;

import java.util.Map;

class FirefoxDriverManager {

  private final FirefoxOptions firefoxOptions;

  public FirefoxDriverManager(WebTestFeedParser testFeedParser) {
    this.firefoxOptions = buildFirefoxOptions(testFeedParser);
  }

  public WebDriver createDriver() {
    WebDriverManager.firefoxdriver().setup();
    return new FirefoxDriver(firefoxOptions);
  }

  private FirefoxOptions buildFirefoxOptions(WebTestFeedParser testFeedParser) {
    Map capabilities = testFeedParser.getDesiredCapabilities().asMap();
    Map preferences = testFeedParser.getPreferences();

    FirefoxOptions options = new FirefoxOptions();
    FirefoxProfile profile = new FirefoxProfile();

    preferences.forEach((preference, value) -> profile.setPreference(preference, (String) value));
    capabilities.forEach(options::setCapability);
    options.setProfile(profile);

    return options;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy