Skip to content

Commit 6499437

Browse files
committed
[java] remove old methods instead of deprecating
1 parent f3a59a8 commit 6499437

File tree

6 files changed

+23
-173
lines changed

6 files changed

+23
-173
lines changed

java/src/org/openqa/selenium/chrome/ChromeDriverInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ public boolean isSupportingBiDi() {
6666
@Override
6767
public boolean isAvailable() {
6868
try {
69-
DriverFinder.getResult(ChromeDriverService.createDefaultService(), getCanonicalCapabilities());
69+
DriverFinder.getResult(
70+
ChromeDriverService.createDefaultService(), getCanonicalCapabilities());
7071
return true;
7172
} catch (NoSuchDriverException e) {
7273
return false;

java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ public Capabilities getDefaultDriverOptions() {
104104
/**
105105
* Configures and returns a new {@link InternetExplorerDriverService} using the default
106106
* configuration. In this configuration, the service will use the IEDriverServer executable
107-
* identified by the {@link org.openqa.selenium.remote.service.DriverFinder#getResult(DriverService,
108-
* Capabilities)}. Each service created by this method will be configured to use a free port on
109-
* the current system.
107+
* identified by the {@link
108+
* org.openqa.selenium.remote.service.DriverFinder#getResult(DriverService, Capabilities)}. Each
109+
* service created by this method will be configured to use a free port on the current system.
110110
*
111111
* @return A new InternetExplorerDriverService using the default configuration.
112112
*/

java/src/org/openqa/selenium/manager/SeleniumManager.java

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,12 @@
2727
import java.nio.file.Path;
2828
import java.nio.file.Paths;
2929
import java.time.Duration;
30-
import java.util.ArrayList;
31-
import java.util.Arrays;
3230
import java.util.List;
33-
import java.util.Map;
3431
import java.util.logging.Level;
3532
import java.util.logging.Logger;
3633
import org.openqa.selenium.Beta;
3734
import org.openqa.selenium.BuildInfo;
38-
import org.openqa.selenium.Capabilities;
39-
import org.openqa.selenium.MutableCapabilities;
4035
import org.openqa.selenium.Platform;
41-
import org.openqa.selenium.Proxy;
4236
import org.openqa.selenium.WebDriverException;
4337
import org.openqa.selenium.json.Json;
4438
import org.openqa.selenium.json.JsonException;
@@ -215,100 +209,6 @@ private synchronized Path getBinary() {
215209
return binary;
216210
}
217211

218-
/**
219-
* Returns the browser binary path when present in the vendor options
220-
*
221-
* @param options browser options used to start the session
222-
* @return the browser binary path when present, only Chrome/Firefox/Edge
223-
* @deprecated see {@see
224-
* org.openqa.selenium.remote.service.DriverFinder#getBrowserBinary(Capabilities)}
225-
*/
226-
private String getBrowserBinary(Capabilities options) {
227-
List<String> vendorOptionsCapabilities =
228-
Arrays.asList("moz:firefoxOptions", "goog:chromeOptions", "ms:edgeOptions");
229-
for (String vendorOptionsCapability : vendorOptionsCapabilities) {
230-
if (options.asMap().containsKey(vendorOptionsCapability)) {
231-
try {
232-
@SuppressWarnings("unchecked")
233-
Map<String, Object> vendorOptions =
234-
(Map<String, Object>) options.getCapability(vendorOptionsCapability);
235-
return (String) vendorOptions.get("binary");
236-
} catch (Exception e) {
237-
LOG.warning(
238-
String.format(
239-
"Exception while retrieving the browser binary path. %s: %s",
240-
options, e.getMessage()));
241-
}
242-
}
243-
}
244-
return null;
245-
}
246-
247-
/**
248-
* Determines the location of the correct driver.
249-
*
250-
* @param options Browser Options instance.
251-
* @return the location of the driver.
252-
* @deprecated use {@link #getResult(List)} instead with the list of arguments.
253-
*/
254-
@Deprecated
255-
public Result getDriverPath(Capabilities options, boolean offline) {
256-
Path binaryFile = getBinary();
257-
if (binaryFile == null) {
258-
return null;
259-
}
260-
261-
List<String> arguments = new ArrayList<>();
262-
arguments.add("--browser");
263-
arguments.add(options.getBrowserName());
264-
arguments.add("--language-binding");
265-
arguments.add("java");
266-
arguments.add("--output");
267-
arguments.add("json");
268-
269-
if (!options.getBrowserVersion().isEmpty()) {
270-
arguments.add("--browser-version");
271-
arguments.add(options.getBrowserVersion());
272-
// We know the browser binary path, we don't need the browserVersion.
273-
// Useful when "beta" is specified as browserVersion, but the browser driver cannot match it.
274-
if (options instanceof MutableCapabilities) {
275-
((MutableCapabilities) options).setCapability("browserVersion", (String) null);
276-
}
277-
}
278-
279-
String browserBinary = getBrowserBinary(options);
280-
if (browserBinary != null && !browserBinary.isEmpty()) {
281-
arguments.add("--browser-path");
282-
arguments.add(browserBinary);
283-
}
284-
285-
if (getLogLevel().intValue() <= Level.FINE.intValue()) {
286-
arguments.add("--debug");
287-
}
288-
289-
if (offline) {
290-
arguments.add("--offline");
291-
}
292-
293-
Proxy proxy = Proxy.extractFrom(options);
294-
if (proxy != null) {
295-
if (proxy.getSslProxy() != null) {
296-
arguments.add("--proxy");
297-
arguments.add(proxy.getSslProxy());
298-
} else if (proxy.getHttpProxy() != null) {
299-
arguments.add("--proxy");
300-
arguments.add(proxy.getHttpProxy());
301-
}
302-
}
303-
304-
Result result = runCommand(binaryFile, arguments);
305-
LOG.fine(
306-
String.format(
307-
"Using driver at location: %s, browser at location %s",
308-
result.getDriverPath(), result.getBrowserPath()));
309-
return result;
310-
}
311-
312212
/**
313213
* Executes Selenium Manager to get the locations of the requested assets
314214
*

java/src/org/openqa/selenium/manager/SeleniumManagerOutput.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,19 @@ public void validateDriver() {
149149
}
150150

151151
public void validateAll() {
152-
Map<String, String> entries = Map.of("driver", driverPath, "browser", browserPath);
152+
Map<String, String> entries = Map.of("driver", driverPath, "browser", browserPath);
153153
validate(entries);
154154
}
155155

156156
private void validate(Map<String, String> entries) {
157157
for (Map.Entry<String, String> entry : entries.entrySet()) {
158158
Path filePath = Paths.get(entry.getValue());
159159
if (!Files.exists(filePath)) {
160-
throw new IllegalArgumentException("The path for '" + entry.getKey() +
161-
"' is not a valid file: " + entry.getValue());
160+
throw new IllegalArgumentException(
161+
"The path for '" + entry.getKey() + "' is not a valid file: " + entry.getValue());
162162
} else if (!Files.isExecutable(filePath)) {
163-
throw new IllegalArgumentException("The file at '" + entry.getKey() +
164-
"' is not executable: " + entry.getValue());
163+
throw new IllegalArgumentException(
164+
"The file at '" + entry.getKey() + "' is not executable: " + entry.getValue());
165165
}
166166
}
167167
}

java/src/org/openqa/selenium/remote/service/DriverFinder.java

Lines changed: 10 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@
1717

1818
package org.openqa.selenium.remote.service;
1919

20-
import java.nio.file.Files;
21-
import java.nio.file.Path;
2220
import java.util.ArrayList;
2321
import java.util.Arrays;
2422
import java.util.List;
2523
import java.util.Map;
2624
import java.util.logging.Logger;
2725
import org.openqa.selenium.Capabilities;
28-
import org.openqa.selenium.MutableCapabilities;
2926
import org.openqa.selenium.Proxy;
30-
import org.openqa.selenium.WebDriverException;
3127
import org.openqa.selenium.internal.Require;
3228
import org.openqa.selenium.manager.SeleniumManager;
3329
import org.openqa.selenium.manager.SeleniumManagerOutput.Result;
@@ -44,12 +40,13 @@ public static Result getResult(DriverService service, Capabilities options) {
4440
public static Result getResult(DriverService service, Capabilities options, boolean offline) {
4541
Require.nonNull("Driver service", service);
4642
Require.nonNull("Browser options", options);
47-
String driverName = service.getDriverName();
48-
4943
try {
5044
Result result = new Result(service.getExecutable());
5145
if (result.getDriverPath() != null) {
52-
LOG.fine(String.format("Skipping Selenium Manager, path to %s specified in Service class: %s", driverName, result.getDriverPath()));
46+
LOG.fine(
47+
String.format(
48+
"Skipping Selenium Manager, path to %s specified in Service class: %s",
49+
service.getDriverName(), result.getDriverPath()));
5350
result.validateDriver();
5451
}
5552

@@ -59,67 +56,19 @@ public static Result getResult(DriverService service, Capabilities options, bool
5956
result = SeleniumManager.getInstance().getResult(arguments);
6057
result.validateAll();
6158
} else {
62-
LOG.fine(String.format("Skipping Selenium Manager, path to %s found in system property: %s", driverName, result.getDriverPath()));
59+
LOG.fine(
60+
String.format(
61+
"Skipping Selenium Manager, path to %s found in system property: %s",
62+
service.getDriverName(), result.getDriverPath()));
6363
result.validateDriver();
6464
}
6565

6666
return result;
6767
} catch (RuntimeException e) {
6868
throw new NoSuchDriverException(
69-
String.format("Unable to obtain: %s, error %s", driverName, e.getMessage()), e);
70-
}
71-
}
72-
73-
@Deprecated
74-
public static Result getPath(DriverService service, Capabilities options) {
75-
return getPath(service, options, false);
76-
}
77-
78-
@Deprecated
79-
public static Result getPath(DriverService service, Capabilities options, boolean offline) {
80-
Require.nonNull("Browser options", options);
81-
Result result = new Result(service.getExecutable());
82-
if (result.getDriverPath() != null) {
83-
LOG.fine(
84-
String.format(
85-
"Skipping Selenium Manager, path to %s specified in Service class: %s",
86-
service.getDriverName(), result.getDriverPath()));
87-
}
88-
89-
result = new Result(System.getProperty(service.getDriverProperty()));
90-
if (result.getDriverPath() == null) {
91-
try {
92-
List<String> arguments = toArguments(options, offline);
93-
result = SeleniumManager.getInstance().getResult(arguments);
94-
((MutableCapabilities) options).setCapability("browserVersion", (String) null);
95-
} catch (RuntimeException e) {
96-
throw new WebDriverException(
97-
String.format("Unable to obtain: %s, error %s", options, e.getMessage()), e);
98-
}
99-
} else {
100-
LOG.fine(
101-
String.format(
102-
"Skipping Selenium Manager, path to %s found in system property: %s",
103-
service.getDriverName(), result.getDriverPath()));
69+
String.format("Unable to obtain: %s, error %s", service.getDriverName(), e.getMessage()),
70+
e);
10471
}
105-
106-
String message;
107-
if (result.getDriverPath() == null) {
108-
message = String.format("Unable to locate or obtain %s", service.getDriverName());
109-
} else if (!Files.exists(Path.of(result.getDriverPath()))) {
110-
message =
111-
String.format(
112-
"%s at location %s, does not exist", service.getDriverName(), result.getDriverPath());
113-
} else if (!Files.isExecutable(Path.of(result.getDriverPath()))) {
114-
message =
115-
String.format(
116-
"%s located at %s, cannot be executed",
117-
service.getDriverName(), result.getDriverPath());
118-
} else {
119-
return result;
120-
}
121-
122-
throw new NoSuchDriverException(message);
12372
}
12473

12574
private static List<String> toArguments(Capabilities options, boolean offline) {

java/src/org/openqa/selenium/safari/SafariTechPreviewDriverService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ public Capabilities getDefaultDriverOptions() {
9696
/**
9797
* Configures and returns a new {@link SafariTechPreviewDriverService} using the default
9898
* configuration. In this configuration, the service will use the SafariDriver executable
99-
* identified by the {@link org.openqa.selenium.remote.service.DriverFinder#getResult(DriverService,
100-
* Capabilities)}. Each service created by this method will be configured to use a free port on
101-
* the current system.
99+
* identified by the {@link
100+
* org.openqa.selenium.remote.service.DriverFinder#getResult(DriverService, Capabilities)}. Each
101+
* service created by this method will be configured to use a free port on the current system.
102102
*
103103
* @return A new SafariTechPreviewDriverService using the default configuration.
104104
*/

0 commit comments

Comments
 (0)