aquality.selenium.configuration.driversettings.FirefoxSettings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aquality-selenium Show documentation
Show all versions of aquality-selenium Show documentation
Library around Selenium WebDriver
package aquality.selenium.configuration.driversettings;
import aquality.selenium.browser.BrowserName;
import aquality.selenium.core.utilities.ISettingsFile;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.AbstractDriverOptions;
import java.util.Map;
public class FirefoxSettings extends DriverSettings {
public FirefoxSettings(ISettingsFile settingsFile){
super(settingsFile);
}
@Override
public AbstractDriverOptions> getDriverOptions() {
FirefoxOptions firefoxOptions = new FirefoxOptions();
setCapabilities(firefoxOptions);
setFirefoxPrefs(firefoxOptions);
setFirefoxArgs(firefoxOptions);
firefoxOptions.setPageLoadStrategy(getPageLoadStrategy());
return firefoxOptions;
}
@Override
public String getDownloadDirCapabilityKey() {
return "browser.download.dir";
}
@Override
public BrowserName getBrowserName() {
return BrowserName.FIREFOX;
}
private void setFirefoxPrefs(FirefoxOptions options) {
Map configOptions = getBrowserOptions();
configOptions.forEach((key, value) -> {
if (key.equals(getDownloadDirCapabilityKey())) {
options.addPreference(key, getDownloadDir());
} else if(value instanceof Boolean) {
options.addPreference(key, (boolean) value);
} else if (value instanceof Integer) {
options.addPreference(key, (int) value);
} else if (value instanceof String) {
options.addPreference(key, (String) value);
}
});
}
private void setFirefoxArgs(FirefoxOptions options) {
for (String arg : getBrowserStartArguments()) {
options.addArguments(arg);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy