Skip to content

Commit 4832457

Browse files
committed
Deleting SafariOptions.port, if a user wants to run safaridriver on a specific port it should explicitly instantiate SafariDriverService and pass it to SafariDriver constructor
1 parent d289954 commit 4832457

File tree

2 files changed

+4
-45
lines changed

2 files changed

+4
-45
lines changed

java/client/src/org/openqa/selenium/safari/SafariDriverService.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
import java.io.File;
3131
import java.io.IOException;
32-
import java.net.MalformedURLException;
3332

3433
public class SafariDriverService extends DriverService {
3534

@@ -49,12 +48,11 @@ public static SafariDriverService createDefaultService() {
4948
/**
5049
* Use {@link #createDefaultService()} instead.
5150
*/
52-
@Deprecated
5351
public static SafariDriverService createDefaultService(SafariOptions options) {
5452
File exe = options.getUseTechnologyPreview() ?
5553
TP_SAFARI_DRIVER_EXECUTABLE : SAFARI_DRIVER_EXECUTABLE;
5654
if (exe.exists()) {
57-
return new Builder().usingPort(options.getPort()).usingDriverExecutable(exe).build();
55+
return new Builder().usingDriverExecutable(exe).build();
5856
}
5957
throw new WebDriverException("SafariDriver requires Safari 10 running on OSX El Capitan or greater.");
6058
}
@@ -64,7 +62,7 @@ static SafariDriverService createDefaultService(Capabilities caps) {
6462
}
6563

6664
@Override
67-
protected void waitUntilAvailable() throws MalformedURLException {
65+
protected void waitUntilAvailable() {
6866
try {
6967
PortProber.waitForPortUp(getUrl().getPort(), 20, SECONDS);
7068
} catch (RuntimeException e) {

java/client/src/org/openqa/selenium/safari/SafariOptions.java

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.openqa.selenium.WebDriverException;
2626
import org.openqa.selenium.remote.CapabilityType;
2727

28-
import java.io.IOException;
2928
import java.util.Map;
3029
import java.util.TreeMap;
3130

@@ -56,14 +55,11 @@ public class SafariOptions extends MutableCapabilities {
5655
private interface Option {
5756
String CLEAN_SESSION = "cleanSession";
5857
String TECHNOLOGY_PREVIEW = "technologyPreview";
59-
String PORT = "port";
6058
}
6159

6260
private Map<String, Object> options = new TreeMap<>();
6361

6462
public SafariOptions() {
65-
options.put(Option.PORT, 0);
66-
6763
setUseTechnologyPreview(false);
6864
useCleanSession(false);
6965

@@ -108,33 +104,14 @@ public static SafariOptions fromCapabilities(Capabilities capabilities)
108104
if (cap instanceof SafariOptions) {
109105
return (SafariOptions) cap;
110106
} 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);
116108
} else {
117109
return new SafariOptions();
118110
}
119111
}
120112

121113
// Setters
122114

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-
138115
/**
139116
* Instruct the SafariDriver to delete all existing session data when starting a new session.
140117
* This includes browser history, cache, cookies, HTML5 local storage, and HTML5 databases.
@@ -199,17 +176,6 @@ public SafariOptions setProxy(Proxy proxy) {
199176

200177
// Getters
201178

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-
213179
/**
214180
* @return Whether the SafariDriver should erase all session data before launching Safari.
215181
* @see #setUseCleanSession(boolean)
@@ -235,14 +201,9 @@ public boolean getUseTechnologyPreview() {
235201
*
236202
* @return A {@link SafariOptions} instance associated with these extensions.
237203
*/
238-
private static SafariOptions fromJsonMap(Map<?, ?> options) throws IOException {
204+
private static SafariOptions fromJsonMap(Map<?, ?> options) {
239205
SafariOptions safariOptions = new SafariOptions();
240206

241-
Number port = (Number) options.get(Option.PORT);
242-
if (port != null) {
243-
safariOptions.setPort(port.intValue());
244-
}
245-
246207
Boolean useCleanSession = (Boolean) options.get(Option.CLEAN_SESSION);
247208
if (useCleanSession != null) {
248209
safariOptions.useCleanSession(useCleanSession);

0 commit comments

Comments
 (0)