Search in sources :

Example 6 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project kotlin by JetBrains.

the class SeleniumFireFox method createFirefoxDriver.

public static FirefoxDriver createFirefoxDriver() {
    FirefoxProfile profile = new FirefoxProfile();
    FirefoxDriver answer = new FirefoxDriver(profile);
    return answer;
}
Also used : FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile)

Example 7 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project jlineup by otto-de.

the class BrowserUtils method getFirefoxProfileWithDisabledAnimatedGifs.

private FirefoxProfile getFirefoxProfileWithDisabledAnimatedGifs() {
    FirefoxProfile firefoxProfileHeadless = new FirefoxProfile();
    firefoxProfileHeadless.setPreference("image.animation_mode", "none");
    return firefoxProfileHeadless;
}
Also used : FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile)

Example 8 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project zeppelin by apache.

the class WebDriverManager method getWebDriver.

public static WebDriver getWebDriver() {
    WebDriver driver = null;
    if (driver == null) {
        try {
            FirefoxBinary ffox = new FirefoxBinary();
            if ("true".equals(System.getenv("TRAVIS"))) {
                // xvfb is supposed to
                ffox.setEnvironmentProperty("DISPLAY", ":99");
            // run with DISPLAY 99
            }
            int firefoxVersion = WebDriverManager.getFirefoxVersion();
            LOG.info("Firefox version " + firefoxVersion + " detected");
            downLoadsDir = FileUtils.getTempDirectory().toString();
            String tempPath = downLoadsDir + "/firebug/";
            downloadFireBug(firefoxVersion, tempPath);
            final String firebugPath = tempPath + "firebug.xpi";
            final String firepathPath = tempPath + "firepath.xpi";
            FirefoxProfile profile = new FirefoxProfile();
            profile.setPreference("browser.download.folderList", 2);
            profile.setPreference("browser.download.dir", downLoadsDir);
            profile.setPreference("browser.helperApps.alwaysAsk.force", false);
            profile.setPreference("browser.download.manager.showWhenStarting", false);
            profile.setPreference("browser.download.manager.showAlertOnComplete", false);
            profile.setPreference("browser.download.manager.closeWhenDone", true);
            profile.setPreference("app.update.auto", false);
            profile.setPreference("app.update.enabled", false);
            profile.setPreference("dom.max_script_run_time", 0);
            profile.setPreference("dom.max_chrome_script_run_time", 0);
            profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-ustar,application/octet-stream,application/zip,text/csv,text/plain");
            profile.setPreference("network.proxy.type", 0);
            profile.addExtension(new File(firebugPath));
            profile.addExtension(new File(firepathPath));
            driver = new FirefoxDriver(ffox, profile);
        } catch (Exception e) {
            LOG.error("Exception in WebDriverManager while FireFox Driver ", e);
        }
    }
    if (driver == null) {
        try {
            driver = new ChromeDriver();
        } catch (Exception e) {
            LOG.error("Exception in WebDriverManager while ChromeDriver ", e);
        }
    }
    if (driver == null) {
        try {
            driver = new SafariDriver();
        } catch (Exception e) {
            LOG.error("Exception in WebDriverManager while SafariDriver ", e);
        }
    }
    String url;
    if (System.getenv("url") != null) {
        url = System.getenv("url");
    } else {
        url = "http://localhost:8080";
    }
    long start = System.currentTimeMillis();
    boolean loaded = false;
    driver.manage().timeouts().implicitlyWait(AbstractZeppelinIT.MAX_IMPLICIT_WAIT, TimeUnit.SECONDS);
    driver.get(url);
    while (System.currentTimeMillis() - start < 60 * 1000) {
        // wait for page load
        try {
            (new WebDriverWait(driver, 30)).until(new ExpectedCondition<Boolean>() {

                @Override
                public Boolean apply(WebDriver d) {
                    return d.findElement(By.xpath("//i[@tooltip='WebSocket Connected']")).isDisplayed();
                }
            });
            loaded = true;
            break;
        } catch (TimeoutException e) {
            LOG.info("Exception in WebDriverManager while WebDriverWait ", e);
            driver.navigate().to(url);
        }
    }
    if (loaded == false) {
        fail();
    }
    return driver;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) IOException(java.io.IOException) TimeoutException(org.openqa.selenium.TimeoutException) SafariDriver(org.openqa.selenium.safari.SafariDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) FirefoxBinary(org.openqa.selenium.firefox.FirefoxBinary) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) File(java.io.File) TimeoutException(org.openqa.selenium.TimeoutException)

Example 9 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project Asqatasun by Asqatasun.

the class ProfileFactory method getProfile.

/**
     * 
     * @return 
     *      a set-up Firefox profile
     */
private FirefoxProfile getProfile(boolean loadImage) {
    if (StringUtils.isNotBlank(pathToPreSetProfile)) {
        File presetProfileDir = new File(pathToPreSetProfile);
        if (presetProfileDir.exists() && presetProfileDir.canRead() && presetProfileDir.canExecute() && presetProfileDir.canWrite()) {
            Logger.getLogger(this.getClass()).debug("Start firefox profile with path " + presetProfileDir.getAbsolutePath());
            return new FirefoxProfile(presetProfileDir);
        } else {
            Logger.getLogger(this.getClass()).debug("The profile with path " + presetProfileDir.getAbsolutePath() + " doesn't exist or don't have permissions");
        }
    }
    Logger.getLogger(this.getClass()).debug("Start firefox with fresh new profile");
    FirefoxProfile firefoxProfile = new FirefoxProfile();
    setUpPreferences(firefoxProfile, loadImage);
    //        setUpExtensions(firefoxProfile);
    setUpProxy(firefoxProfile);
    return firefoxProfile;
}
Also used : FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) File(java.io.File)

Example 10 with FirefoxProfile

use of org.openqa.selenium.firefox.FirefoxProfile in project ORCID-Source by ORCID.

the class ShibbolethTest method createFireFoxDriverWithModifyHeaders.

private WebDriver createFireFoxDriverWithModifyHeaders(List<Pair<String, String>> headers) throws IOException {
    FirefoxProfile fireFoxProfile = new FirefoxProfile();
    File modifyHeaders = new File(System.getProperty("user.dir") + "/src/test/resources/modify-headers-0.7.1.1.xpi");
    fireFoxProfile.setEnableNativeEvents(false);
    fireFoxProfile.addExtension(modifyHeaders);
    fireFoxProfile.setPreference("modifyheaders.headers.count", headers.size());
    for (int i = 0; i < headers.size(); i++) {
        fireFoxProfile.setPreference("modifyheaders.headers.action" + i, "Add");
        fireFoxProfile.setPreference("modifyheaders.headers.name" + i, headers.get(i).getLeft());
        fireFoxProfile.setPreference("modifyheaders.headers.value" + i, headers.get(i).getRight());
        fireFoxProfile.setPreference("modifyheaders.headers.enabled" + i, true);
    }
    fireFoxProfile.setPreference("modifyheaders.config.active", true);
    fireFoxProfile.setPreference("modifyheaders.config.alwaysOn", true);
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setBrowserName("firefox");
    capabilities.setPlatform(org.openqa.selenium.Platform.ANY);
    capabilities.setCapability(FirefoxDriver.PROFILE, fireFoxProfile);
    // Marionette does not allow untrusted certs yet
    capabilities.setCapability(FirefoxDriver.MARIONETTE, false);
    WebDriver webDriver = new FirefoxDriver(capabilities);
    return webDriver;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) File(java.io.File)

Aggregations

FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)15 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)10 File (java.io.File)8 WebDriver (org.openqa.selenium.WebDriver)4 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)4 IOException (java.io.IOException)3 FirefoxBinary (org.openqa.selenium.firefox.FirefoxBinary)3 URL (java.net.URL)2 TimeoutException (org.openqa.selenium.TimeoutException)2 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)2 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)2 SafariDriver (org.openqa.selenium.safari.SafariDriver)2 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)2 PublicAtsApi (com.axway.ats.common.PublicAtsApi)1 ElementNotFoundException (com.axway.ats.uiengine.exceptions.ElementNotFoundException)1 SeleniumOperationException (com.axway.ats.uiengine.exceptions.SeleniumOperationException)1 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)1 JBrowserDriver (com.machinepublishers.jbrowserdriver.JBrowserDriver)1 ProxyConfig (com.machinepublishers.jbrowserdriver.ProxyConfig)1 Type (com.machinepublishers.jbrowserdriver.ProxyConfig.Type)1