Java 类org.openqa.selenium.firefox.internal.ProfilesIni 实例源码

项目:play2-prototypen    文件:CommonBrowserNavigationTest.java   
/**
     * @author andre.tschirch
     * 
     * Example test method for using specific Firefox version e.g. v17. 
     *   
     * Test method for running a successful login and the right presentation of
     * the activity state of the admin navigation link, which must be active,
     * for browser Firefox.
     */
//  @Test
    public void navAdminFirefox17() {
        ProfilesIni profile = new ProfilesIni();
        FirefoxProfile firefoxProfile = profile.getProfile("firefox17");
        WebDriver driver = new FirefoxDriver(new FirefoxBinary(new File("D:/schatzsuche/firefox17/firefox.exe")), firefoxProfile);
        TestBrowser browser = Helpers.testBrowser(driver, 3333);

        TestServer server = Helpers.testServer(3333, Helpers.fakeApplication());
        TestServer startedServer = null;
        try {
            server.start();
            startedServer = server;
            new NavAdminCallbackComposite().invoke(browser);
        } catch(Throwable t) {
            throw new RuntimeException(t);
        } finally {
            if(browser != null) {
                browser.quit();
            }
            if(startedServer != null) {
                startedServer.stop();
            }
        }
    }
项目:automation-test-engine    文件:FirefoxFeatureProfile.java   
/**
 * Instantiates a new profile creator.
 *
 * @param profileName
 *            the profile name
 */

public FirefoxFeatureProfile(   String profileName) {
    super(); 
    if (StringUtils.isEmpty(profileName)) {
        throw new IllegalArgumentException();
    }
    this.profileName = profileName;

    ProfilesIni profileIni = new ProfilesIni();
    FirefoxProfile tmpProfile = profileIni.getProfile(profileName);
    if (null == tmpProfile) {
        throw new IllegalArgumentException(
                "Could not find the browser profile.");
    } else {
        this.profile = tmpProfile;
    }

}
项目:selenium-java-robot    文件:LocalRobotizedBrowserFactory.java   
public static LocalRobotizedBrowserFactory createRobotizedWebDriverFactory(String browser) {
    if (BrowserType.FIREFOX.equalsIgnoreCase(browser)) {
        FirefoxProfile firefoxProfile = null;
        String firefoxProfileProperty = System.getProperty("webdriver.firefox.profile");
        if (firefoxProfileProperty == null) {
            ProfilesIni allProfiles = new ProfilesIni();
            // Use the default profile to make extensions available,
            // and especially to ease debugging with Firebug
            firefoxProfile = allProfiles.getProfile("default");
        }
        return new LocalFirefox(firefoxProfile);
    } else if (BrowserType.SAFARI.equalsIgnoreCase(browser)) {
        return new LocalSafari();
    } else if (BrowserType.CHROME.equalsIgnoreCase(browser)) {
        return new LocalBrowser<ChromeDriver>(ChromeDriver.class);
    } else if ("chrome-debug".equalsIgnoreCase(browser)) {
        return new LocalDebuggableChrome();
    } else if (BrowserType.IE.equalsIgnoreCase(browser)) {
        return new LocalBrowser<InternetExplorerDriver>(InternetExplorerDriver.class);
    } else {
        throw new RuntimeException("Unknown browser value: " + browser);
    }

}
项目:candybean    文件:FirefoxInterface.java   
@Override
public void start() throws CandybeanException {
    String profileName = candybean.config.getValue("browser.firefox.profile", "default");
    File ffBinaryPath = new File(candybean.config.getPathValue("browser.firefox.binary"));
    if(!ffBinaryPath.exists()){
        String error = "Unable to find firefox browser driver from the specified location in the configuration file! \n"
                + "Please add a configuration to the candybean config file for key \"browser.firefox.binary\" that"
                + "indicates the location of the binary.";
        logger.severe(error);
        throw new CandybeanException(error);
    } else {
        FirefoxProfile ffProfile = (new ProfilesIni()).getProfile(profileName);
        FirefoxBinary ffBinary = new FirefoxBinary(ffBinaryPath);
        logger.info("Instantiating Firefox with profile name: "
                + profileName + " and binary path: " + ffBinaryPath);
        super.wd = new FirefoxDriver(ffBinary, ffProfile);
        super.start(); // requires wd to be instantiated first
    }
}
项目:scientific-publishing    文件:BaseTest.java   
@Before
public void setUp() throws MalformedURLException {
    FirefoxProfile profile = new FirefoxProfile();
    ProfilesIni profilesIni = new ProfilesIni();
    profile = profilesIni.getProfile("default");
    // The following 3 settings disable the 'Firefox automatically sends some data to Mozilla...'
    profile.setPreference("datareporting.healthreport.uploadEnabled", false);
    profile.setPreference("datareporting.healthreport.service.enabled", false);
    profile.setPreference("datareporting.healthreport.service.firstRun", false);
    webDriver = new FirefoxDriver(profile); //TODO headless? phantom js?
    webDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
项目:selenium-on-steroids    文件:WebDriverHelper.java   
/**
 * Creates a FirefoxDriver that has the supplied user agent.
 * 
 * @param userAgent
 *            the user agent
 * @return a new FirefoxDriver instance containing the specified user agent
 *         settings
 */

public static WebDriver getFirefoxDriverWithUserAgent(final String userAgent) {
    ProfilesIni allProfiles = new ProfilesIni();
    FirefoxProfile profile = allProfiles.getProfile("default");
    profile.setPreference("general.useragent.override", userAgent);
    profile.setAcceptUntrustedCertificates(true);
    profile.setAssumeUntrustedCertificateIssuer(true);
    WebDriver driver = new FirefoxDriver(profile);
    return driver;

}
项目:eMonocot    文件:WebDriverFacade.java   
/**
 *
 * @return the webdriver
 * @throws IOException if there is a problem loading the
 *                     properties file
 */
private WebDriver createWebDriver() throws IOException {
    Resource propertiesFile = new ClassPathResource(
            "META-INF/spring/application.properties");
    Properties properties = new Properties();
    properties.load(propertiesFile.getInputStream());
    String webdriverMode = properties.getProperty("selenium.webdriver.mode", "local");
    String driverName = properties.getProperty("selenium.webdriver.impl", "org.openqa.selenium.firefox.FirefoxDriver");
    WebDriverBrowserType browser = WebDriverBrowserType.fromString(driverName);
    String display = properties.getProperty("selenium.display.port", ":0");
    if (webdriverMode.equals("local")) {
        switch (browser) {
        case CHROME:
            String chromeLocation = properties
            .getProperty("selenium.webdriver.chromedriver.location");
            Map<String,String> environment = new HashMap<String,String>();
            environment.put("DISPLAY", display);
            ChromeDriverService chromeService = new ChromeDriverService.Builder()
            .usingDriverExecutable(new File(chromeLocation))
            .usingAnyFreePort().withEnvironment(environment).build();
            chromeService.start();
            return new RemoteWebDriver(chromeService.getUrl(),
                    DesiredCapabilities.chrome());
        case SAFARI:
            return new SafariDriver();
        case INTERNET_EXPLORER:
            String  internetExplorerLocation = properties
            .getProperty("selenium.webdriver.ie.location");
            InternetExplorerDriverService ieService = InternetExplorerDriverService.createDefaultService();
            ieService.start();
            return new RemoteWebDriver(ieService.getUrl(),
                    DesiredCapabilities.internetExplorer());
        case FIREFOX:
        default:
            FirefoxBinary firefoxBinary = new FirefoxBinary();
            firefoxBinary.setEnvironmentProperty("DISPLAY", display);
            ProfilesIni allProfiles = new ProfilesIni();
            FirefoxProfile profile = allProfiles.getProfile("default");
            return new FirefoxDriver(firefoxBinary, profile);
        }
    } else {

        DesiredCapabilities capabilities = new DesiredCapabilities();
        switch (browser) {
        case CHROME:
            capabilities = DesiredCapabilities.chrome();
            break;
        case INTERNET_EXPLORER:
            capabilities = DesiredCapabilities.internetExplorer();
            break;
        case SAFARI:
            capabilities = DesiredCapabilities.safari();
            break;
        case FIREFOX:
        default:
            capabilities = DesiredCapabilities.firefox();
        }
        String platformName = properties.getProperty("selenium.webdriver.platformName", "LINUX");
        WebDriverPlatformType platform = WebDriverPlatformType.valueOf(platformName);
        switch (platform) {
        case MAC:
            capabilities.setPlatform(Platform.MAC);
            break;
        case WINDOWS:
            capabilities.setPlatform(Platform.WINDOWS);
            break;
        case LINUX:
        default:
            capabilities.setPlatform(Platform.LINUX);
        }
        return new RemoteWebDriver(new URL("http://build.e-monocot.org:4444/wd/hub"), capabilities);
    }
}
项目:selenium-on-steroids    文件:WebDriverHelper.java   
/**
 * This method adds browser specific capabilities like FirefoxProfile and
 * ChromeOptions.
 * 
 * @param capabilities
 *            specific capabilities
 * @param builder
 *            the builder object containing the properties
 */
private static void addSpecificBrowserSettings(
        final DesiredCapabilities capabilities, final Builder builder) {
    if (capabilities.getBrowserName().equalsIgnoreCase(
            Constants.Browsers.FIREFOX)) {
        LOG.info("Browser is Firefox. Getting local profile");

        FirefoxProfile profile = null;

        if (builder.profileLocation != null
                && !"".equalsIgnoreCase(builder.profileLocation)) {
            profile = new FirefoxProfile(new File(builder.profileLocation));
            LOG.info("Firefox profile: " + builder.profileLocation);
        } else {
            LOG.info("Loading Firefox default sprofile");
            ProfilesIni allProfiles = new ProfilesIni();
            allProfiles.getProfile("default");
        }

        capabilities.setCapability(FirefoxDriver.PROFILE, profile);

        if (builder.userAgent != null) {
            profile.setPreference("general.useragent.override",
                    builder.userAgent);
        }

    } else if (capabilities.getBrowserName().equalsIgnoreCase(
            Constants.Browsers.CHROME)) {
        ChromeOptions options = new ChromeOptions();
        if (builder.userAgent != null) {
            options.addArguments("user-agent=" + builder.userAgent);
        }
        capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    } else if (capabilities.getBrowserName().equalsIgnoreCase(
            Constants.Browsers.IE)) {
        capabilities
                .setCapability(
                        InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
                        builder.flakinessForIe);
    }
    LOG.info("Finished adding specific browser settings");
}
项目:alimama    文件:Test.java   
public static void main3(String[] args) throws Exception {

            FirefoxProfile fp = new FirefoxProfile();
            ProfilesIni allProfiles = new ProfilesIni();
            fp = allProfiles.getProfile("default");
            WebDriver driver = new FirefoxDriver(fp);
            driver.get("http://www.baidu.com/");


        }