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

com.sdl.selenium.utils.browsers.HtmlUnitConfigReader Maven / Gradle / Ivy

Go to download

Automated Acceptance Testing. Selenium and Selenium WebDriver test framework for web applications. (optimized for dynamic html, ExtJS, Bootstrap, complex UI, simple web applications/sites)

There is a newer version: 20.08.432.0_b2d2a09
Show newest version
package com.sdl.selenium.utils.browsers;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.LocalFileDetector;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.io.IOException;
import java.net.URL;

public class HtmlUnitConfigReader extends AbstractBrowserConfigReader {

    private static final String DEFAULT_CONFIG =
            "\n browser=htmlunit";

    public HtmlUnitConfigReader() {
        this(null);
    }

    public HtmlUnitConfigReader(String resourcePath) {
        super(resourcePath, DEFAULT_CONFIG);
    }

    @Override
    public WebDriver createDriver() throws IOException {
        return new HtmlUnitDriver(true);
    }

    @Override
    public WebDriver createDriver(URL remoteUrl) throws IOException {
        if (isRemoteDriver()) {
            RemoteWebDriver driver = new RemoteWebDriver(remoteUrl, DesiredCapabilities.htmlUnit());
            driver.setFileDetector(new LocalFileDetector());
            return driver;
        } else {
            return createDriver();
        }
    }

    @Override
    public boolean isSilentDownload() {
        return !"".equals(getProperty("browser.download.dir"));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy