29
29
import com .google .common .collect .Maps ;
30
30
import com .google .common .collect .Sets ;
31
31
32
+ import com .sun .javafx .runtime .SystemProperties ;
33
+
32
34
import org .openqa .selenium .Capabilities ;
33
35
import org .openqa .selenium .OutputType ;
34
36
import org .openqa .selenium .Platform ;
71
73
* profile directly. This allows multiple instances of firefox to be started.
72
74
*/
73
75
public class FirefoxDriver extends RemoteWebDriver implements Killable {
76
+
77
+ public interface SystemProperty {
78
+ String BROWSER_BINARY = "webdriver.firefox.bin" ;
79
+ String BROWSER_LOGFILE = "webdriver.firefox.logfile" ;
80
+ String BROWSER_LIBRARY_PATH = "webdriver.firefox.library.path" ;
81
+ String BROWSER_PROFILE = "webdriver.firefox.profile" ;
82
+
83
+ /**
84
+ * System property that defines the location of the webdriver.xpi browser extension to install
85
+ * in the browser. If not set, the prebuilt extension bundled with this class will be used
86
+ * instead.
87
+ */
88
+ String DRIVER_XPI_PROPERTY = "webdriver.firefox.driver" ;
89
+
90
+ /**
91
+ * Boolean system property that instructs FirefoxDriver to use Marionette backend.
92
+ */
93
+ String DRIVER_USE_MARIONETTE = "webdriver.firefox.marionette" ;
94
+ }
95
+
74
96
public static final String BINARY = "firefox_binary" ;
75
97
public static final String PROFILE = "firefox_profile" ;
76
98
@@ -79,7 +101,7 @@ public class FirefoxDriver extends RemoteWebDriver implements Killable {
79
101
80
102
// For now, only enable native events on Windows
81
103
public static final boolean USE_MARIONETTE = Boolean .parseBoolean (
82
- System .getProperty ("webdriver.firefox.marionette" ));
104
+ System .getProperty (SystemProperty . DRIVER_USE_MARIONETTE ));
83
105
84
106
// Accept untrusted SSL certificates.
85
107
@ Deprecated
@@ -100,18 +122,18 @@ public FirefoxDriver(FirefoxProfile profile) {
100
122
}
101
123
102
124
public FirefoxDriver (Capabilities desiredCapabilities ) {
103
- this (getBinary (desiredCapabilities ), extractProfile (desiredCapabilities , null ),
125
+ this (getBinary (desiredCapabilities ), extractProfile (desiredCapabilities , null ),
104
126
desiredCapabilities );
105
127
}
106
-
128
+
107
129
public FirefoxDriver (Capabilities desiredCapabilities , Capabilities requiredCapabilities ) {
108
- this (getBinary (desiredCapabilities ), extractProfile (desiredCapabilities , requiredCapabilities ),
130
+ this (getBinary (desiredCapabilities ), extractProfile (desiredCapabilities , requiredCapabilities ),
109
131
desiredCapabilities , requiredCapabilities );
110
132
}
111
133
112
- private static FirefoxProfile extractProfile (Capabilities desiredCapabilities ,
134
+ private static FirefoxProfile extractProfile (Capabilities desiredCapabilities ,
113
135
Capabilities requiredCapabilities ) {
114
-
136
+
115
137
FirefoxProfile profile = null ;
116
138
Object raw = null ;
117
139
if (desiredCapabilities != null && desiredCapabilities .getCapability (PROFILE ) != null ) {
@@ -132,10 +154,10 @@ private static FirefoxProfile extractProfile(Capabilities desiredCapabilities,
132
154
}
133
155
}
134
156
profile = getProfile (profile );
135
-
157
+
136
158
populateProfile (profile , desiredCapabilities );
137
159
populateProfile (profile , requiredCapabilities );
138
-
160
+
139
161
return profile ;
140
162
}
141
163
@@ -152,10 +174,10 @@ static void populateProfile(FirefoxProfile profile, Capabilities capabilities) {
152
174
profile .setAcceptUntrustedCertificates (acceptCerts );
153
175
}
154
176
if (capabilities .getCapability (LOGGING_PREFS ) != null ) {
155
- LoggingPreferences logsPrefs =
177
+ LoggingPreferences logsPrefs =
156
178
(LoggingPreferences ) capabilities .getCapability (LOGGING_PREFS );
157
179
for (String logtype : logsPrefs .getEnabledLogTypes ()) {
158
- profile .setPreference ("webdriver.log." + logtype ,
180
+ profile .setPreference ("webdriver.log." + logtype ,
159
181
logsPrefs .getLevel (logtype ).intValue ());
160
182
}
161
183
}
@@ -185,8 +207,8 @@ public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile) {
185
207
public FirefoxDriver (FirefoxBinary binary , FirefoxProfile profile , Capabilities capabilities ) {
186
208
this (binary , profile , capabilities , null );
187
209
}
188
-
189
- public FirefoxDriver (FirefoxBinary binary , FirefoxProfile profile ,
210
+
211
+ public FirefoxDriver (FirefoxBinary binary , FirefoxProfile profile ,
190
212
Capabilities desiredCapabilities , Capabilities requiredCapabilities ) {
191
213
super (new LazyCommandExecutor (binary , profile ),
192
214
dropCapabilities (desiredCapabilities , BINARY , PROFILE ),
@@ -251,12 +273,13 @@ protected void startClient() {
251
273
252
274
private static FirefoxProfile getProfile (FirefoxProfile profile ) {
253
275
FirefoxProfile profileToUse = profile ;
254
- String suggestedProfile = System .getProperty ("webdriver.firefox.profile" );
276
+ String suggestedProfile = System .getProperty (SystemProperty . BROWSER_PROFILE );
255
277
if (profileToUse == null && suggestedProfile != null ) {
256
278
profileToUse = new ProfilesIni ().getProfile (suggestedProfile );
257
279
if (profileToUse == null ) {
258
- throw new WebDriverException ("Firefox profile '" + suggestedProfile
259
- + "' named in system property 'webdriver.firefox.profile' not found" );
280
+ throw new WebDriverException (String .format (
281
+ "Firefox profile '%s' named in system property '%s' not found" ,
282
+ suggestedProfile , SystemProperty .BROWSER_PROFILE ));
260
283
}
261
284
} else if (profileToUse == null ) {
262
285
profileToUse = new FirefoxProfile ();
@@ -292,7 +315,7 @@ protected void stopClient() {
292
315
293
316
/**
294
317
* Drops capabilities that we shouldn't send over the wire.
295
- *
318
+ *
296
319
* Used for capabilities which aren't BeanToJson-convertable, and are only used by the local
297
320
* launcher.
298
321
*/
0 commit comments