Examples of FirefoxProfile


Examples of org.openqa.selenium.firefox.FirefoxProfile

    // Determine the requested browser type
    switch (configuration.getBrowser()) {
      case firefox:
        if (configuration.getProxyConfiguration() != null) {
          FirefoxProfile profile = new FirefoxProfile();

          profile.setPreference("network.proxy.http", configuration
                  .getProxyConfiguration().getHostname());
          profile.setPreference("network.proxy.http_port", configuration
                  .getProxyConfiguration().getPort());
          profile.setPreference("network.proxy.type", configuration
                  .getProxyConfiguration().getType().toInt());
          /* use proxy for everything, including localhost */
          profile.setPreference("network.proxy.no_proxies_on", "");

          return WebDriverBackedEmbeddedBrowser.withDriver(new FirefoxDriver(profile),
                  filterAttributes, crawlWaitReload, crawlWaitEvent);
        }

View Full Code Here

Examples of org.openqa.selenium.firefox.FirefoxProfile

  }

  private EmbeddedBrowser newFireFoxBrowser(ImmutableSortedSet<String> filterAttributes,
          long crawlWaitReload, long crawlWaitEvent) {
    if (configuration.getProxyConfiguration() != null) {
      FirefoxProfile profile = new FirefoxProfile();
      String lang = configuration.getBrowserConfig().getLangOrNull();
      if (!Strings.isNullOrEmpty(lang)) {
        profile.setPreference("intl.accept_languages", lang);
      }

      profile.setPreference("network.proxy.http", configuration.getProxyConfiguration()
              .getHostname());
      profile.setPreference("network.proxy.http_port", configuration
              .getProxyConfiguration().getPort());
      profile.setPreference("network.proxy.type", configuration.getProxyConfiguration()
              .getType().toInt());
      /* use proxy for everything, including localhost */
      profile.setPreference("network.proxy.no_proxies_on", "");

      return WebDriverBackedEmbeddedBrowser.withDriver(new FirefoxDriver(profile),
              filterAttributes, crawlWaitReload, crawlWaitEvent);
    }

View Full Code Here

Examples of org.openqa.selenium.firefox.FirefoxProfile

  }

  public WebDriver newWebDriver() {
    WebDriver driver;
    if ("firefox".equalsIgnoreCase(browser)) {
      FirefoxProfile profile;
      // Load FireFox-profile if present
      if (profileDirectory != null) {
        profile = new FirefoxProfile(profileDirectory);
        LOG.info("Firefox profile successfully loaded");
      }
      else {
        profile = new FirefoxProfile();
      }

      if (customProfilePreferencesFile != null) {
        PreferencesWrapper prefs = loadFirefoxPreferences();

        prefs.addTo(profile);
        try {
          StringWriter writer = new StringWriter(512);
          prefs.writeTo(writer);
          LOG.info("Added properties to firefox profile: " + writer.toString());
        } catch (IOException e) {
          LOG.error("Unable to log firefox profile settings", e);
        }
      }

      // Ensure we deal with untrusted and unverified hosts.
      profile.setAcceptUntrustedCertificates(true);
      profile.setAssumeUntrustedCertificateIssuer(true);

      driver = new FirefoxDriver(profile);
    } else if ("iexplore".equalsIgnoreCase(browser)) {
      driver = new InternetExplorerDriver();
    } else if ("chrome".equalsIgnoreCase(browser)) {
View Full Code Here

Examples of org.openqa.selenium.firefox.FirefoxProfile

  }

  private EmbeddedBrowser newFireFoxBrowser(ImmutableSortedSet<String> filterAttributes,
          long crawlWaitReload, long crawlWaitEvent) {
    if (configuration.getProxyConfiguration() != null) {
      FirefoxProfile profile = new FirefoxProfile();
      String lang = configuration.getBrowserConfig().getLangOrNull();
      if (!Strings.isNullOrEmpty(lang)) {
        profile.setPreference("intl.accept_languages", lang);
      }

      profile.setPreference("network.proxy.http", configuration.getProxyConfiguration()
              .getHostname());
      profile.setPreference("network.proxy.http_port", configuration
              .getProxyConfiguration().getPort());
      profile.setPreference("network.proxy.type", configuration.getProxyConfiguration()
              .getType().toInt());
      /* use proxy for everything, including localhost */
      profile.setPreference("network.proxy.no_proxies_on", "");

      return WebDriverBackedEmbeddedBrowser.withDriver(new FirefoxDriver(profile),
              filterAttributes, crawlWaitReload, crawlWaitEvent);
    }

View Full Code Here

Examples of org.openqa.selenium.firefox.FirefoxProfile

    }

    protected WebDriver createFireFoxWebDriver() throws Exception {
        File profile = new File(profileDir, "firefox");
        profile.mkdirs();
        return new FirefoxDriver(new FirefoxProfile(profile));
    }
View Full Code Here

Examples of org.openqa.selenium.firefox.FirefoxProfile

    // Determine the requested browser type
    switch (configuration.getBrowser()) {
      case firefox:
        if (configuration.getProxyConfiguration() != null) {
          FirefoxProfile profile = new FirefoxProfile();

          profile.setPreference("network.proxy.http", configuration
                  .getProxyConfiguration().getHostname());
          profile.setPreference("network.proxy.http_port", configuration
                  .getProxyConfiguration().getPort());
          profile.setPreference("network.proxy.type", configuration
                  .getProxyConfiguration().getType().toInt());
          /* use proxy for everything, including localhost */
          profile.setPreference("network.proxy.no_proxies_on", "");

          return WebDriverBackedEmbeddedBrowser.withDriver(new FirefoxDriver(profile),
                  filterAttributes, crawlWaitReload, crawlWaitEvent);
        }

View Full Code Here

Examples of org.openqa.selenium.firefox.FirefoxProfile

        if (Validate.nonEmpty(binary)) {
            Validate.isExecutable(binary, "Firefox binary does not point to a valid executable,  " + binary);
        }

        // set firefox profile from path if specified
        FirefoxProfile firefoxProfile;
        if (Validate.nonEmpty(profile)) {
            Validate.isValidPath(profile, "Firefox profile does not point to a valid path " + profile);
            firefoxProfile = new FirefoxProfile(new File(profile));
        }
        else {
            firefoxProfile = new FirefoxProfile();
        }

        capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);

        final String firefoxExtensions = (String) capabilities.getCapability("firefoxExtensions");
        // no check is needed here, it will return empty array if null
        for (String extensionPath : StringUtils.tokenize(firefoxExtensions)) {
            try {
                firefoxProfile.addExtension(new File(extensionPath));
            } catch (IOException e) {
                throw new IllegalArgumentException("Cannot read XPI extension file: " + extensionPath, e);
            }
        }

        // add user preferences from file
        final String userPreferences = (String) capabilities.getCapability("firefoxUserPreferences");
        if (Validate.nonEmpty(userPreferences)) {
            Validate.isValidPath(userPreferences, "User preferences does not point to a valid path " + userPreferences);
            // we need to manually parse preferences, as Selenium provides no way to set these value
            for (Map.Entry<String, Object> preference : FirefoxPrefsReader.getPreferences(new File(userPreferences)).entrySet()) {
                String key = preference.getKey();
                Object value = preference.getValue();
                if (value instanceof Boolean) {
                    firefoxProfile.setPreference(key, (Boolean) value);
                }
                else if (value instanceof Integer) {
                    firefoxProfile.setPreference(key, (Integer) value);
                }
                else if (value instanceof String) {
                    firefoxProfile.setPreference(key, (String) value);
                }
            }
        }

        return SecurityActions.newInstance(configuration.getImplementationClass(), new Class<?>[] { Capabilities.class },
View Full Code Here

Examples of org.openqa.selenium.firefox.FirefoxProfile

        if (capabilities != null) {
            return new FirefoxDriver(capabilities);
        }

        ProfilesIni allProfiles = new ProfilesIni();
        FirefoxProfile myProfile = allProfiles.getProfile("WebDriver");
        if (myProfile == null) {
            File ffDir = new File(System.getProperty("user.dir")+ File.separator+"ffProfile");
            if (!ffDir.exists()) {
                ffDir.mkdir();
            }
            myProfile = new FirefoxProfile(ffDir);
        }
        myProfile.setAcceptUntrustedCertificates(true);
        myProfile.setAssumeUntrustedCertificateIssuer(true);
        myProfile.setPreference("webdriver.load.strategy", "unstable");
        if (capabilities == null) {
            capabilities = new DesiredCapabilities();
        }
        capabilities.setCapability(FirefoxDriver.PROFILE, myProfile);
        return new FirefoxDriver(capabilities);
View Full Code Here

Examples of org.openqa.selenium.firefox.FirefoxProfile

  }

  private EmbeddedBrowser newFireFoxBrowser(ImmutableSortedSet<String> filterAttributes,
          long crawlWaitReload, long crawlWaitEvent) {
    if (configuration.getProxyConfiguration() != null) {
      FirefoxProfile profile = new FirefoxProfile();
      String lang = configuration.getBrowserConfig().getLangOrNull();
      if (!Strings.isNullOrEmpty(lang)) {
        profile.setPreference("intl.accept_languages", lang);
      }

      profile.setPreference("network.proxy.http", configuration.getProxyConfiguration()
              .getHostname());
      profile.setPreference("network.proxy.http_port", configuration
              .getProxyConfiguration().getPort());
      profile.setPreference("network.proxy.type", configuration.getProxyConfiguration()
              .getType().toInt());
      /* use proxy for everything, including localhost */
      profile.setPreference("network.proxy.no_proxies_on", "");

      return WebDriverBackedEmbeddedBrowser.withDriver(new FirefoxDriver(profile),
              filterAttributes, crawlWaitReload, crawlWaitEvent);
    }

View Full Code Here

Examples of org.openqa.selenium.firefox.FirefoxProfile

public class FirefoxWithProfileTest extends IntegrationTest {
  @Test
  public void createFirefoxWithCustomProfile() {
    assumeTrue(WebDriverRunner.isFirefox());

    FirefoxProfile profile = createFirefoxProfileWithExtensions();
    WebDriver driver = new FirefoxDriver(profile);
    driver.manage().window().maximize();
    try {
      WebDriverRunner.setWebDriver(driver);
      openFile("page_with_selects_without_jquery.html");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.