Created
May 23, 2012 12:35
-
-
Save freynaud/2775033 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Eclipse Workspace Patch 1.0 | |
#P selenium | |
Index: java/client/src/org/openqa/selenium/firefox/FirefoxBinary.java | |
=================================================================== | |
--- java/client/src/org/openqa/selenium/firefox/FirefoxBinary.java (revision 16072) | |
+++ java/client/src/org/openqa/selenium/firefox/FirefoxBinary.java (working copy) | |
@@ -19,8 +19,10 @@ | |
import static java.util.concurrent.TimeUnit.SECONDS; | |
+import com.google.common.collect.Lists; | |
import com.google.common.collect.Maps; | |
+import org.openqa.selenium.Capabilities; | |
import org.openqa.selenium.Platform; | |
import org.openqa.selenium.WebDriverException; | |
import org.openqa.selenium.firefox.internal.Executable; | |
@@ -31,8 +33,11 @@ | |
import java.io.File; | |
import java.io.IOException; | |
import java.io.OutputStream; | |
+import java.util.ArrayList; | |
+import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.HashSet; | |
+import java.util.List; | |
import java.util.Map; | |
import java.util.Set; | |
@@ -47,15 +52,22 @@ | |
private CommandLine process; | |
private OutputStream stream; | |
private long timeout = SECONDS.toMillis(45); | |
- | |
+ private List<String> extraArguments = Lists.newArrayList(); | |
+ | |
+ | |
public FirefoxBinary() { | |
- this(null); | |
+ this(null,null); | |
} | |
public FirefoxBinary(File pathToFirefoxBinary) { | |
+ this(pathToFirefoxBinary,null); | |
+ } | |
+ | |
+ public FirefoxBinary(File pathToFirefoxBinary,List<String> arguments) { | |
executable = new Executable(pathToFirefoxBinary); | |
+ extraArguments = arguments; | |
} | |
- | |
+ | |
protected boolean isOnLinux() { | |
return Platform.getCurrent().is(Platform.LINUX); | |
} | |
@@ -74,8 +86,11 @@ | |
modifyLinkLibraryPath(profileDir); | |
} | |
+ List<String> allParams = Lists.newArrayList(commandLineFlags); | |
+ allParams.addAll(extraArguments); | |
+ | |
CommandLine command = new CommandLine( | |
- getExecutable().getPath(), commandLineFlags); | |
+ getExecutable().getPath(), allParams.toArray(new String[allParams.size()])); | |
command.setEnvironmentVariables(getExtraEnv()); | |
executable.setLibraryPath(command, getExtraEnv()); | |
@@ -262,4 +277,25 @@ | |
process.destroy(); | |
} | |
} | |
+ | |
+ | |
+ /** | |
+ * extract the extra flags passed via the capabilities object that | |
+ * will be used when starting firefox. | |
+ * | |
+ * @param caps | |
+ * @return | |
+ */ | |
+ public static List<String> extractSwitches(Capabilities caps) { | |
+ Object flags = caps.getCapability(FirefoxDriver.FLAGS); | |
+ if (flags ==null){ | |
+ return new ArrayList<String>(); | |
+ } else if (flags instanceof String[]){ | |
+ return Arrays.asList((String[])flags); | |
+ }else { | |
+ return (List<String>)flags; | |
+ } | |
+ | |
+ | |
+ } | |
} | |
Index: java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java | |
=================================================================== | |
--- java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java (revision 16072) | |
+++ java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java (working copy) | |
@@ -79,6 +79,7 @@ | |
public static final boolean ASSUME_UNTRUSTED_ISSUER = true; | |
protected FirefoxBinary binary; | |
+ public static final String FLAGS = "firefox.arguments"; | |
public FirefoxDriver() { | |
this(new FirefoxBinary(), null); | |
@@ -131,11 +132,12 @@ | |
} | |
private static FirefoxBinary getBinary(Capabilities capabilities) { | |
- if (capabilities.getCapability(BINARY) != null) { | |
- File file = new File((String) capabilities.getCapability(BINARY)); | |
- return new FirefoxBinary(file); | |
+ File file = null; | |
+ if (capabilities.getCapability(BINARY) != null) { | |
+ file = new File((String) capabilities.getCapability(BINARY)); | |
} | |
- return new FirefoxBinary(); | |
+ FirefoxBinary firefoxBinary = new FirefoxBinary(file,FirefoxBinary.extractSwitches(capabilities)); | |
+ return firefoxBinary; | |
} | |
public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment