Created
March 31, 2012 09:56
-
-
Save stackedsax/2261402 to your computer and use it in GitHub Desktop.
Provides a way to load a locally-stored Firefox profile and maintains the ability to send a profile as a json string
This file contains hidden or 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
Index: java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java | |
=================================================================== | |
--- java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java (revision 16421) | |
+++ java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java (working copy) | |
@@ -101,10 +101,13 @@ | |
if (raw instanceof FirefoxProfile) { | |
profile = (FirefoxProfile) raw; | |
} else if (raw instanceof String) { | |
- try { | |
- profile = FirefoxProfile.fromJson((String) raw); | |
- } catch (IOException e) { | |
- throw new WebDriverException(e); | |
+ profile = new ProfilesIni().getProfile((String) raw); | |
+ if (profile == null){ | |
+ try { | |
+ profile = FirefoxProfile.fromJson((String) raw); | |
+ } catch (IOException e) { | |
+ throw new WebDriverException(e); | |
+ } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I want to use a profile that lives on the remote machine. The code you pasted would pass "profileName" from the machine that's executing the test. Since we start up browsers many many times during our suites, I want to reduce the amount of information that gets sent over the wire.
We already provide this sort of behaviour, but the ability is limited to a single profile: we can set the -Dwebdriver.firefox.profile in the command line startup of the node. This suggests that priming a remote test machine with a special profile is a perfectly legitimate way of organizing test profiles. My change merely expands this ability to allow us to select any profiles that exist on the remote test machine.
It amounts to a 2-line change. ProfilesIni returns null if the string does not match any profile name saved in the Map created by ProfilesIni of the profiles.ini file. It seems like a fairly safe thing to do and would allow people to do what they're trying to do. In my searching for a solution on this, I noticed a number of comments which indicated people were trying to do this exact same thing.