1717
1818package org .openqa .selenium .firefox ;
1919
20+ import static java .util .stream .Collectors .toMap ;
21+ import static org .openqa .selenium .firefox .FirefoxDriver .Capability .BINARY ;
22+ import static org .openqa .selenium .firefox .FirefoxDriver .Capability .MARIONETTE ;
23+ import static org .openqa .selenium .firefox .FirefoxDriver .Capability .PROFILE ;
24+ import static org .openqa .selenium .remote .Browser .FIREFOX ;
25+
2026import org .openqa .selenium .Capabilities ;
2127import org .openqa .selenium .WebDriverException ;
2228import org .openqa .selenium .internal .Require ;
2733import java .io .IOException ;
2834import java .io .UncheckedIOException ;
2935import java .nio .file .Path ;
30- import java .util .*;
31-
32- import static java .util .stream .Collectors .toMap ;
33- import static org .openqa .selenium .firefox .FirefoxDriver .Capability .BINARY ;
34- import static org .openqa .selenium .firefox .FirefoxDriver .Capability .MARIONETTE ;
35- import static org .openqa .selenium .firefox .FirefoxDriver .Capability .PROFILE ;
36- import static org .openqa .selenium .remote .Browser .FIREFOX ;
36+ import java .util .ArrayList ;
37+ import java .util .Arrays ;
38+ import java .util .Collections ;
39+ import java .util .HashMap ;
40+ import java .util .List ;
41+ import java .util .Map ;
42+ import java .util .Objects ;
43+ import java .util .Optional ;
44+ import java .util .Set ;
45+ import java .util .TreeMap ;
46+ import java .util .TreeSet ;
3747
3848/**
3949 * Manage firefox specific settings in a way that geckodriver can understand.
@@ -158,11 +168,11 @@ public FirefoxOptions setLegacy(boolean legacy) {
158168 }
159169
160170 /**
161- * @deprecated This method will be deleted and will not be replaced.
171+ * Constructs a {@link FirefoxBinary} and returns that to be used, and because of this is only
172+ * useful when actually starting firefox.
162173 */
163- @ Deprecated
164- public boolean isLegacy () {
165- return legacy ;
174+ public FirefoxBinary getBinary () {
175+ return getBinaryOrNull ().orElseGet (FirefoxBinary ::new );
166176 }
167177
168178 public FirefoxOptions setBinary (FirefoxBinary binary ) {
@@ -181,14 +191,6 @@ public FirefoxOptions setBinary(String path) {
181191 return setFirefoxOption (Keys .BINARY , path );
182192 }
183193
184- /**
185- * Constructs a {@link FirefoxBinary} and returns that to be used, and because of this is only
186- * useful when actually starting firefox.
187- */
188- public FirefoxBinary getBinary () {
189- return getBinaryOrNull ().orElseGet (FirefoxBinary ::new );
190- }
191-
192194 public Optional <FirefoxBinary > getBinaryOrNull () {
193195 Object binary = firefoxOptions .get (Keys .BINARY .key ());
194196 if (!(binary instanceof String )) {
@@ -207,16 +209,6 @@ public Optional<FirefoxBinary> getBinaryOrNull() {
207209 return Optional .of (toReturn );
208210 }
209211
210- public FirefoxOptions setProfile (FirefoxProfile profile ) {
211- Require .nonNull ("Profile" , profile );
212-
213- try {
214- return setFirefoxOption (Keys .PROFILE , profile .toJson ());
215- } catch (IOException e ) {
216- throw new UncheckedIOException (e );
217- }
218- }
219-
220212 public FirefoxProfile getProfile () {
221213 Object rawProfile = firefoxOptions .get (Keys .PROFILE .key ());
222214 if (rawProfile == null ) {
@@ -234,6 +226,16 @@ public FirefoxProfile getProfile() {
234226 }
235227 }
236228
229+ public FirefoxOptions setProfile (FirefoxProfile profile ) {
230+ Require .nonNull ("Profile" , profile );
231+
232+ try {
233+ return setFirefoxOption (Keys .PROFILE , profile .toJson ());
234+ } catch (IOException e ) {
235+ throw new UncheckedIOException (e );
236+ }
237+ }
238+
237239 public FirefoxOptions addArguments (String ... arguments ) {
238240 addArguments (Arrays .asList (arguments ));
239241 return this ;
0 commit comments