Example usage for org.openqa.selenium.firefox FirefoxProfile FirefoxProfile

List of usage examples for org.openqa.selenium.firefox FirefoxProfile FirefoxProfile

Introduction

In this page you can find the example usage for org.openqa.selenium.firefox FirefoxProfile FirefoxProfile.

Prototype

public FirefoxProfile() 

Source Link

Usage

From source file:com.consol.citrus.selenium.client.WebClient.java

License:Apache License

private FirefoxProfile createFireFoxProfile() {
    FirefoxProfile fp = new FirefoxProfile();

    fp.setAcceptUntrustedCertificates(true);
    fp.setAssumeUntrustedCertificateIssuer(false);

    /* set custom download folder */
    fp.setPreference("browser.download.dir", temporaryStorage.toFile().getAbsolutePath());

    /* default download folder, set to 2 to use custom download folder */
    fp.setPreference("browser.download.folderList", 2);

    /* comma separated list if MIME types to save without asking */
    fp.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/plain");

    /* do not show download manager */
    fp.setPreference("browser.download.manager.showWhenStarting", false);

    fp.setEnableNativeEvents(true);// ww  w.j av  a2s  .c  o  m

    return fp;
}

From source file:com.consol.citrus.selenium.endpoint.SeleniumBrowserConfiguration.java

License:Apache License

/**
 * Gets the firefoxProfile.//from   w w w  .j  a v  a 2s  . c om
 *
 * @return
 */
public FirefoxProfile getFirefoxProfile() {
    if (firefoxProfile == null) {
        firefoxProfile = new FirefoxProfile();

        firefoxProfile.setAcceptUntrustedCertificates(true);
        firefoxProfile.setAssumeUntrustedCertificateIssuer(false);

        /* default download folder, set to 2 to use custom download folder */
        firefoxProfile.setPreference("browser.download.folderList", 2);

        /* comma separated list if MIME types to save without asking */
        firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/plain");

        /* do not show download manager */
        firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);

        firefoxProfile.setEnableNativeEvents(true);
    }

    return firefoxProfile;
}

From source file:com.crawljax.plugins.testilizer.generated.claroline_EXND.GeneratedTestCase11.java

public static FirefoxProfile getProfile() {
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("network.proxy.http", "localhost");
    profile.setPreference("network.proxy.http_port", 3128);
    profile.setPreference("network.proxy.type", 1);
    /* use proxy for everything, including localhost */
    profile.setPreference("network.proxy.no_proxies_on", "");
    return profile;
}

From source file:com.dhenton9000.selenium.generic.GenericAutomationRepository.java

/**
 * set up the driver with configuration parameters
 *
 */// w  w w.  ja v a  2 s .  co m
private void configureDriver() {

    LoggingPreferences logs = new LoggingPreferences();
    logs.enable(LogType.BROWSER, Level.SEVERE);
    logs.enable(LogType.CLIENT, Level.SEVERE);
    logs.enable(LogType.DRIVER, Level.SEVERE);
    logs.enable(LogType.PERFORMANCE, Level.SEVERE);
    logs.enable(LogType.PROFILER, Level.SEVERE);
    logs.enable(LogType.SERVER, Level.SEVERE);

    String driverTypeString = this.config.getString("test.selenium.browser");
    if (driverTypeString == null) {
        throw new RuntimeException("must specify 'test.selenium.browser' in prop file");
    }

    DRIVER_TYPES driverType = DRIVER_TYPES.valueOf(driverTypeString);
    LOG.debug(" found driver type " + driverType.toString());
    if (driverType == null) {
        throw new RuntimeException("cannot find driver type of " + driverTypeString);
    }

    switch (driverType) {
    case FireFox:
    default:
        DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
        desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS, logs);

        // sets the driver to automatically skip download dialog
        // and save csv,xcel files to a temp directory
        // that directory is set in the constructor and has a trailing
        // slash
        FirefoxProfile firefoxProfile = new FirefoxProfile();
        firefoxProfile.setPreference("browser.download.folderList", 2);
        firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);

        String target = this.getTempDownloadPath();
        firefoxProfile.setPreference("browser.download.dir", target);
        firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk",
                "text/csv,application/vnd.ms-excel");

        desiredCapabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);

        LOG.debug("creating firefox driver");
        driver = new FirefoxDriver(desiredCapabilities);
        LOG.debug("got firefox driver");
        break;
    case InternetExplorer:
        break;
    case Opera:
        break;
    case Safari:
        break;
    case Chrome:
        break;

    }
    driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
    LOG.debug("driver is loaded via config " + driver.toString());

}

From source file:com.expedia.lux.accountsettingstest.core.CreateWebDriverHelper.java

License:Open Source License

/**
 * Create webdriver entry/*from   ww  w  .j a  v  a2 s  . co  m*/
 * 
 * @param testName
 * @param browserType
 *            1 is chrome, 2 is firefox, 0 is internet explorer, 3 is safari
 * @param logging
 * @return
 */
public static WebDriver createWebDriver(String testName, String testBrowser) {
    WebDriver driver = null;
    String isCloud = String.valueOf(isRemoteTest);

    if (!isRemoteTest) {
        DesiredCapabilities capabillities = new DesiredCapabilities();
        capabillities.setCapability(CapabilityType.SUPPORTS_WEB_STORAGE, false);
        switch (testBrowser.toUpperCase()) {
        case "IE":
            // Need set iedriver.exe file path
            System.setProperty("webdriver.ie.driver", ieDriverPath);
            driver = new InternetExplorerDriver(capabillities);
            break;
        case "FF":
            // TODO: Not stable
            capabillities.setCapability(FirefoxDriver.BINARY, new FirefoxBinary(new File(firefoxPath)));
            FirefoxProfile profile = new FirefoxProfile();
            profile.setAcceptUntrustedCertificates(true);
            capabillities.setCapability(FirefoxDriver.PROFILE, profile);
            driver = new FirefoxDriver(capabillities);
            break;
        case "SF":
            // TODO: No one's machine has safari installed in SZ
            driver = new SafariDriver(capabillities);
            break;
        default:
            // Need set the chromedriver.exe file path.
            System.setProperty("webdriver.chrome.driver", chromeDriverPath);
            driver = new ChromeDriver(capabillities);
            break;
        }
    } else {
        DesiredCapabilities capabillities;
        switch (testBrowser.toUpperCase()) {
        case "IE9":
            capabillities = DesiredCapabilities.internetExplorer();
            capabillities.setCapability(CapabilityType.VERSION, "9");
            break;
        case "FF":
            capabillities = DesiredCapabilities.firefox();
            break;
        case "SF":
            capabillities = DesiredCapabilities.safari();
            capabillities.setCapability("platform", "OS X 10.6");
            capabillities.setCapability("version", "5");
            capabillities.setCapability("disable-popup-handler", true);
            break;
        case "IE7":
            capabillities = DesiredCapabilities.internetExplorer();
            capabillities.setCapability(CapabilityType.VERSION, "7");
            break;
        case "IE8":
            capabillities = DesiredCapabilities.internetExplorer();
            capabillities.setCapability(CapabilityType.VERSION, "8");
            break;
        case "IE10":
            capabillities = DesiredCapabilities.internetExplorer();
            capabillities.setCapability(CapabilityType.VERSION, "10");
            break;
        case "IE11":
            capabillities = DesiredCapabilities.internetExplorer();
            capabillities.setCapability("version", "11");
            break;
        case "OP":
            capabillities = DesiredCapabilities.opera();
            capabillities.setCapability("version", "12");
            break;
        //Note: may not support HTTPS via sauceConnect with mobile platform yet
        case "IOS":
            capabillities = DesiredCapabilities.iphone();
            capabillities.setCapability("version", "6.1");
            capabillities.setCapability("platform", "OS X 10.8");
            capabillities.setCapability("device-orientation", "portrait");
            capabillities.setCapability("disable-popup-handler", true);
            break;
        case "AND":
            capabillities = DesiredCapabilities.android();
            capabillities.setCapability("version", "4.0");
            capabillities.setCapability("platform", "Linux");
            capabillities.setCapability("device-type", "tablet");
            capabillities.setCapability("device-orientation", "portrait");
            break;
        case "SAUCE":
            return createWebDriverSaucelab(testName + " (SauceLabs)");
        default:
            capabillities = DesiredCapabilities.chrome();
            capabillities.setBrowserName("chrome");
            break;
        }

        try {
            driver = new RemoteWebDriver(new URL("http://10.208.52.16:5555/wd/hub"), capabillities);
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    fillBrowserName(testBrowser, isCloud);
    return driver;
}

From source file:com.fullteaching.backend.e2e.FirefoxUser.java

License:Apache License

public FirefoxUser(String userName, int timeOfWaitInSeconds) {
    super(userName, timeOfWaitInSeconds);

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("acceptInsecureCerts", true);
    FirefoxProfile profile = new FirefoxProfile();

    // This flag avoids granting the access to the camera
    profile.setPreference("media.navigator.permission.disabled", true);
    // This flag force to use fake user media (synthetic video of multiple color)
    profile.setPreference("media.navigator.streams.fake", true);

    capabilities.setCapability(FirefoxDriver.PROFILE, profile);

    String eusApiURL = System.getenv("ET_EUS_API");

    if (eusApiURL == null) {
        this.driver = new FirefoxDriver(capabilities);
    } else {/*  w ww . j a  va  2 s .c  o m*/
        try {
            capabilities.setBrowserName("firefox");

            this.driver = new RemoteWebDriver(new URL(eusApiURL), capabilities);

        } catch (MalformedURLException e) {
            throw new RuntimeException("Exception creaing eusApiURL", e);
        }
    }

    this.driver.manage().timeouts().setScriptTimeout(this.timeOfWaitInSeconds, TimeUnit.SECONDS);

    this.configureDriver();
}

From source file:com.ggasoftware.uitest.utils.WebDriverWrapper.java

License:Open Source License

/**
 * initialization FirefoxDriver/*w  w  w  . j av  a2 s  .c  om*/
 */
public static void initFirefoxDriver() {
    ReporterNGExt.logTechnical("Initialization Firefox Driver");
    FirefoxProfile profile = new FirefoxProfile();
    profile.setAcceptUntrustedCertificates(true);
    profile.setAssumeUntrustedCertificateIssuer(true);
    profile.setEnableNativeEvents(true);
    profile.setPreference("javascript.enabled", true);
    profile.setPreference("dom.max_script_run_time", 0);
    profile.setPreference("dom.max_chrome_script_run_time", 0);
    setWebDriver(new FirefoxDriver(profile));
    setTimeout(TIMEOUT);
    getDriver().manage().window().maximize();
}

From source file:com.googlesites.CaptchaTest.java

@Test(groups = "sikuli")
public void createSite() {

    FirefoxProfile profile = new FirefoxProfile();
    driver = new FirefoxDriver(new FirefoxBinary(new File(Config.getPropertyValue("firefoxLocation"))),
            profile);//from w  ww  .  ja va 2s  .c  o m
    WebDriverInstance wdi = new WebDriverInstance();
    wdi.setCurrentDriver(driver);
    driver.manage().window().maximize();
    sitesURLs.add("blanksitezzz");
    sitesURLs.add("intranetlintranetl111");
    sitesURLs.add("alf12opitds");
    sitesURLs.add("soccttttttttttttttttttttt");
    overview = new Overview(driver);
    overview.navigateToOverviewPage();
    loginPage = overview.navigateToLogin();
    sites = loginPage.logIn("johnjjones02@gmail.com", "MyPasswordIsC0@l");
    sites.verifyTheOnlySitesAre(sitesURLs);
    createSite = sites.clickOnCreateButton();
    createSite.createSite("Gollum1124", "siteyy1");
    driver.close();
}

From source file:com.gorillalogic.agents.html.WebDriverAgent.java

License:Open Source License

@Override
public void start() {
    try {//from  w  w w .  jav a2  s  .  com
        ping();
    } catch (Exception e) {
        FirefoxProfile profile = new FirefoxProfile();
        try {
            Method m = FirefoxProfile.class.getDeclaredMethod("addExtension", String.class,
                    org.openqa.selenium.firefox.internal.Extension.class);
            m.setAccessible(true);
            //            ClasspathExtension extension = new ClasspathExtension(SeleniumCommandProcessor.class,
            //                    "/" + SeleniumCommandProcessor.class.getPackage().getName().replace(".", "/") + "/selenium-ide.xpi");            
            //            m.invoke(profile, "selenium-ide", extension);            
            ClasspathExtension extension = new ClasspathExtension(SeleniumCommandProcessor.class,
                    "/" + SeleniumCommandProcessor.class.getPackage().getName().replace(".", "/")
                            + "/monkeytalk-recorder.xpi");
            m.invoke(profile, "monkeytalk-recorder", extension);
        } catch (Exception ex) {
            throw new IllegalStateException(
                    "Unable to install monkeytalk-recorder firefox extension: " + ex.getMessage());
        }
        scp = new SeleniumCommandProcessor(BrowserType.FIREFOX, getHost(), new FirefoxDriver(profile));
    }
}

From source file:com.huangyunkun.jviff.service.WebDriverManager.java

License:Apache License

private static WebDriver createWebDriver() {
    FirefoxProfile firefoxProfile = new FirefoxProfile();
    firefoxProfile.setPreference("app.update.auto", false);
    firefoxProfile.setPreference("app.update.enabled", false);
    //TODO:Disable proxy first, will add a proxy setting option later
    firefoxProfile.setPreference("network.proxy.type", 0);
    WebDriver driver = new FirefoxDriver(firefoxProfile);
    return driver;
}