25
25
import org .openqa .selenium .WebDriverException ;
26
26
import org .openqa .selenium .remote .CapabilityType ;
27
27
28
- import java .io .IOException ;
29
28
import java .util .Map ;
30
29
import java .util .TreeMap ;
31
30
@@ -56,14 +55,11 @@ public class SafariOptions extends MutableCapabilities {
56
55
private interface Option {
57
56
String CLEAN_SESSION = "cleanSession" ;
58
57
String TECHNOLOGY_PREVIEW = "technologyPreview" ;
59
- String PORT = "port" ;
60
58
}
61
59
62
60
private Map <String , Object > options = new TreeMap <>();
63
61
64
62
public SafariOptions () {
65
- options .put (Option .PORT , 0 );
66
-
67
63
setUseTechnologyPreview (false );
68
64
useCleanSession (false );
69
65
@@ -108,33 +104,14 @@ public static SafariOptions fromCapabilities(Capabilities capabilities)
108
104
if (cap instanceof SafariOptions ) {
109
105
return (SafariOptions ) cap ;
110
106
} else if (cap instanceof Map ) {
111
- try {
112
- return SafariOptions .fromJsonMap ((Map <?, ?>) cap );
113
- } catch (IOException e ) {
114
- throw new WebDriverException (e );
115
- }
107
+ return SafariOptions .fromJsonMap ((Map <?, ?>) cap );
116
108
} else {
117
109
return new SafariOptions ();
118
110
}
119
111
}
120
112
121
113
// Setters
122
114
123
- /**
124
- * Set the port the {@link SafariDriverService} should be started on. Defaults to 0, in which case
125
- * the server selects a free port.
126
- *
127
- * @param port The port the {@link SafariDriverService} should be started on,
128
- * or 0 if the server should select a free port.
129
- * @deprecated Create a {@link SafariDriverService} to specify driver service port and pass
130
- * the service instance to a {@link SafariDriver} constructor.
131
- */
132
- @ Deprecated
133
- SafariOptions setPort (int port ) {
134
- options .put (Option .PORT , port );
135
- return this ;
136
- }
137
-
138
115
/**
139
116
* Instruct the SafariDriver to delete all existing session data when starting a new session.
140
117
* This includes browser history, cache, cookies, HTML5 local storage, and HTML5 databases.
@@ -199,17 +176,6 @@ public SafariOptions setProxy(Proxy proxy) {
199
176
200
177
// Getters
201
178
202
- /**
203
- * @return The port the {@link SafariDriverService} should be started on.
204
- * If 0, the server should select a free port.
205
- * @see #setPort(int)
206
- * @deprecated Getters are not needed in browser Options classes.
207
- */
208
- @ Deprecated
209
- public int getPort () {
210
- return ((Number ) options .getOrDefault (Option .PORT , 0 )).intValue ();
211
- }
212
-
213
179
/**
214
180
* @return Whether the SafariDriver should erase all session data before launching Safari.
215
181
* @see #setUseCleanSession(boolean)
@@ -235,14 +201,9 @@ public boolean getUseTechnologyPreview() {
235
201
*
236
202
* @return A {@link SafariOptions} instance associated with these extensions.
237
203
*/
238
- private static SafariOptions fromJsonMap (Map <?, ?> options ) throws IOException {
204
+ private static SafariOptions fromJsonMap (Map <?, ?> options ) {
239
205
SafariOptions safariOptions = new SafariOptions ();
240
206
241
- Number port = (Number ) options .get (Option .PORT );
242
- if (port != null ) {
243
- safariOptions .setPort (port .intValue ());
244
- }
245
-
246
207
Boolean useCleanSession = (Boolean ) options .get (Option .CLEAN_SESSION );
247
208
if (useCleanSession != null ) {
248
209
safariOptions .useCleanSession (useCleanSession );
0 commit comments