Package org.openqa.selenium.firefox

Examples of org.openqa.selenium.firefox.FirefoxProfile


        capabilities.setCapability(CapabilityType.PROXY, createProxy());
        return capabilities;
    }

    FirefoxProfile createProfile() {
        FirefoxProfile profile = new FirefoxProfile();
        String userAgentOverride = getUserAgentOverride();
        if(StringUtils.isNotEmpty(userAgentOverride)) {
            profile.setPreference("general.useragent.override", userAgentOverride);
        }
        return profile;
    }
View Full Code Here


  }
 
  @Override
  public WebDriver createDriver(File browserPath, Map<String, String> driverOptions)
  {
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("capability.policy.default.Window.QueryInterface", "allAccess");
    profile.setPreference("capability.policy.default.Window.frameElement.get","allAccess");
    profile.setPreference("capability.policy.default.HTMLDocument.compatMode.get", "allAccess");
        profile.setPreference("capability.policy.default.Location.href","allAccess");
        profile.setPreference("capability.policy.default.Window.pageXOffset","allAccess");
        profile.setPreference("capability.policy.default.Window.pageYOffset","allAccess");
        profile.setPreference("capability.policy.default.Window.frameElement","allAccess");
        profile.setPreference("capability.policy.default.Window.frameElement.get","allAccess");
        profile.setPreference("capability.policy.default.Window.QueryInterface","allAccess");
        profile.setPreference("capability.policy.default.Window.mozInnerScreenY","allAccess");
        profile.setPreference("capability.policy.default.Window.mozInnerScreenX","allAccess");
   
    System.setProperty("webdriver.firefox.bin", browserPath.getPath());
   
    for(String optionKey : driverOptions.keySet())
    {
      String optionValue = driverOptions.get(optionKey);
      profile.setPreference(optionKey, optionValue);
    }
   
    return new FirefoxDriver(profile);
  }
View Full Code Here

    int hubPort = getProperty("test.hub.port",
        GridBrowserMediaApiTest.DEFAULT_HUB_PORT);

    try {
      if (driverClass.equals(FirefoxDriver.class)) {
        FirefoxProfile profile = new FirefoxProfile();
        // This flag avoids granting the access to the camera
        profile.setPreference("media.navigator.permission.disabled",
            true);
        if (remoteNode != null) {
          DesiredCapabilities capabilities = new DesiredCapabilities();
          capabilities.setCapability(FirefoxDriver.PROFILE, profile);
          capabilities.setBrowserName(DesiredCapabilities.firefox()
View Full Code Here

            // Create FirefoxProfile and set to DesiredCapabilities.
            // (FirefoxProfile object can work with both local and remote FirefoxDriver
            //  see: https://code.google.com/p/selenium/wiki/DesiredCapabilities#Firefox_specific)
            String profileName = driverOptions.get(PROFILE);
            String profileDir = driverOptions.get(PROFILE_DIR);
            FirefoxProfile profile;
            if (profileName != null) {
                if (profileDir != null)
                    throw new IllegalArgumentException("Can't specify both '--profile' and '--profile-dir' at once");
                // see http://code.google.com/p/selenium/wiki/TipsAndTricks
                ProfilesIni allProfiles = new ProfilesIni();
                profile = allProfiles.getProfile(profileName);
                log.info("Firefox profile: {}", profileName);
            } else {
                File dir = new File(profileDir);
                if (!dir.isDirectory())
                    throw new IllegalArgumentException("Missing profile directory: " + profileDir);
                profile = new FirefoxProfile(dir);
                log.info("Firefox profile directory: {}", profileDir);
            }
            if (isRemote) {
                String json;
                try {
                    json = profile.toJson();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                caps.setCapability(FirefoxDriver.PROFILE, json);
                log.info("Convert Firefox profile to JSON: {} bytes", json.length());
View Full Code Here

        final FirefoxBinary binary = new FirefoxBinary();
        decorateFirefoxBinary(binary);
        OverriddenFirefoxDriver firefoxDriver = null;
        if (profileName != null) {
            ProfilesIni allProfilesIni = new ProfilesIni();
            FirefoxProfile profile = allProfilesIni.getProfile(profileName);
            profile.setAcceptUntrustedCertificates(false);
            firefoxDriver = new OverriddenFirefoxDriver(binary, profile);
            delegate.set(firefoxDriver);
        } else {
            firefoxDriver = null;
View Full Code Here

  }

  private EmbeddedBrowser newFireFoxBrowser(ImmutableSortedSet<String> filterAttributes,
          long crawlWaitReload, long crawlWaitEvent) {
    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

        String line = reader.readLine();

        while (line != null) {
          if (line.startsWith("[Profile")) {
            FirefoxProfile profile = newProfile(name, appData, path, isRelative);
            if (profile != null)
              toReturn.put(name, profile);
           
            name = null;
            path = null;
          } else if (line.startsWith("Name=")) {
              name = line.substring("Name=".length());
          } else if (line.startsWith("IsRelative=")) {
            isRelative = line.endsWith("1");
          } else if (line.startsWith("Path=")) {
            path = line.substring("Path=".length());
          }
         
          line = reader.readLine();
        }
    } catch (IOException e) {
        throw new WebDriverException(e);
    } finally {
        try {
            if (reader != null) {
              FirefoxProfile profile = newProfile(name, appData, path, isRelative);
              if (profile != null)
                toReturn.put(name, profile);
             
              reader.close();
            }
View Full Code Here

      super(dir);
    }
  }

  public FirefoxProfile getProfile(String profileName) {
    FirefoxProfile liveProfile = profiles.get(profileName);
    if (liveProfile == null)
      return null;

    // Make a copy of the profile to use
    File tempDir = TemporaryFilesystem.createTempDir("userprofile", "copy");
    try {
      FileHandler.copy(liveProfile.getProfileDir(), tempDir);

      // Delete the old compreg.dat file so that our new extension is registered
      File compreg = new File(tempDir, "compreg.dat");
      if (compreg.exists()) {
        if (!compreg.delete()) {
          throw new WebDriverException("Cannot delete file from copy of profile " + profileName);
        }
      }
    } catch (IOException e) {
      throw new WebDriverException(e);
    }

    FirefoxProfile profile = new ProfileFromDirectory(tempDir);

    if (profile.getPort() == 0)
      profile.setPort(FirefoxDriver.DEFAULT_PORT);
   
    return profile;
  }
View Full Code Here

  }

  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

*/
public class FireFoxBrowser {
  private static Log log = LogFactory.getLog(FireFoxBrowser.class);
 
  public static WebDriver getDriver1() {
    FirefoxProfile firefoxProfile = new FirefoxProfile();

    firefoxProfile.setPreference("network.proxy.type", 1);
    firefoxProfile.setPreference("network.proxy.http", "corp-hts-proxy.mhc");
    firefoxProfile.setPreference("network.proxy.http_port", 8080);
    firefoxProfile.setPreference("network.proxy.ssl", "corp-hts-proxy.mhc");
    firefoxProfile.setPreference("network.proxy.ssl_port", 8080);
    firefoxProfile.setPreference("network.proxy.no_proxies_on", "");

    return new FirefoxDriver(firefoxProfile);
  }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.firefox.FirefoxProfile

Copyright © 2018 www.massapicom. 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.