package org.jbehave.web.selenium;

import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;

/**
 * Provides Firefox WebDriver instances, using a profile if the name 
 * is provided via the system property {@link #FIREFOX_PROFILE}.
 */
public class FirefoxWebDriverProvider extends DelegatingWebDriverProvider {

    public static final String FIREFOX_PROFILE = "JBEHAVE_WEBDRIVER_FIREFOX_PROFILE";

    public void initialize() {
        String profileName = System.getProperty(FIREFOX_PROFILE);
        if (profileName != null) {
            ProfilesIni allProfilesIni = new ProfilesIni();
            FirefoxProfile profile = allProfilesIni.getProfile(profileName);
            profile.setAcceptUntrustedCertificates(false);
            delegate.set(new FirefoxDriver(profile));
        } else {
            delegate.set(new FirefoxDriver());
        }
    }

}
@@ -28,16 +28,66 @@
 enium;%0A%0A
+import org.openqa.selenium.firefox.FirefoxBinary;%0A
 import o
@@ -641,16 +641,123 @@
 OFILE);%0A
+%0A        FirefoxBinary firefoxBinary = new FirefoxBinary();%0A        decorateFirefoxBinary(firefoxBinary);%0A%0A
         
@@ -1022,16 +1022,31 @@
 xDriver(
+firefoxBinary, 
 profile)
@@ -1108,29 +1108,127 @@
 xDriver(
-));%0A        %7D
+firefoxBinary, null));%0A        %7D%0A    %7D%0A%0A    protected void decorateFirefoxBinary(FirefoxBinary firefoxBinary) %7B
 %0A    %7D%0A%0A

allow for firefox binaries to be decorated