Skip to content

Commit

Permalink
[java] Deleting driver-specific deprecated methods and constants
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Apr 7, 2019
1 parent 7ebab0c commit 077f86f
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 177 deletions.
12 changes: 0 additions & 12 deletions java/client/src/org/openqa/selenium/chrome/ChromeOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,6 @@ public ChromeOptions setExperimentalOption(String name, Object value) {
return this;
}

/**
* Returns the value of an experimental option.
*
* @param name The option name.
* @return The option value, or {@code null} if not set.
* @deprecated Getters are not needed in browser Options classes.
*/
@Deprecated
public Object getExperimentalOption(String name) {
return experimentalOptions.get(checkNotNull(name));
}

public ChromeOptions setHeadless(boolean headless) {
args.remove("--headless");
if (headless) {
Expand Down
41 changes: 0 additions & 41 deletions java/client/src/org/openqa/selenium/firefox/FirefoxBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
Expand Down Expand Up @@ -289,44 +288,4 @@ private static Optional<String> getEnvVarIgnoreCase(String var) {
.filter(e -> e.getKey().equalsIgnoreCase(var))
.findFirst().map(Map.Entry::getValue);
}

//------------------------

/**
* @deprecated DriverService is responsible for process management
*/
@Deprecated
public void waitFor() {

}

/**
* @deprecated DriverService is responsible for process management
*/
@Deprecated
public void waitFor(long timeout) {

}

/**
* @deprecated DriverService is responsible for process management
*/
@Deprecated
public String getConsoleOutput() {
return null;
}

/**
* @deprecated DriverService is responsible for process management
*/
@Deprecated
public void setOutputWatcher(OutputStream stream) {
}

/**
* @deprecated DriverService is responsible for process management
*/
@Deprecated
public void quit() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,6 @@ public FirefoxOptions addPreference(String key, String value) {
return this;
}

/**
* @deprecated Use {@link #setLogLevel(FirefoxDriverLogLevel)}
*/
@Deprecated
public FirefoxOptions setLogLevel(Level logLevel) {
setLogLevel(FirefoxDriverLogLevel.fromLevel(logLevel));
return this;
}

public FirefoxOptions setLogLevel(FirefoxDriverLogLevel logLevel) {
this.logLevel = Objects.requireNonNull(logLevel, "Log level must be set");
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;

/**
* Manages the life and death of an GeckoDriver aka 'wires'.
Expand Down Expand Up @@ -117,16 +116,6 @@ public static class Builder extends FirefoxDriverService.Builder<
public Builder() {
}

/**
* @param binary - A custom location where the Firefox binary is available.
*
* @deprecated Use method usingFirefoxBinary instead
*/
@Deprecated
public Builder(FirefoxBinary binary) {
this.firefoxBinary = binary;
}

@Override
protected boolean isLegacy() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ public void start() throws IOException {
addWebDriverExtension(profile);
profileDir = profile.layoutOnDisk();

binary.setOutputWatcher(getOutputStream());

ImmutableMap.Builder<String, String> envBuilder = new ImmutableMap.Builder<String, String>()
.putAll(getEnvironment())
.put("XRE_PROFILE_PATH", profileDir.getAbsolutePath())
Expand Down
54 changes: 9 additions & 45 deletions java/client/src/org/openqa/selenium/ie/InternetExplorerDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@

package org.openqa.selenium.ie;

import com.google.common.base.Preconditions;

import org.openqa.selenium.Capabilities;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.FileDetector;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.service.DriverCommandExecutor;
Expand Down Expand Up @@ -141,76 +138,44 @@ public class InternetExplorerDriver extends RemoteWebDriver {
*/
public final static String IE_SWITCHES = "ie.browserCommandLineSwitches";

/**
* Port which is used by default.
*/
private final static int DEFAULT_PORT = 0;

public InternetExplorerDriver() {
this(null, null, DEFAULT_PORT);
this(null, null);
}

/**
* @deprecated Use {@link #InternetExplorerDriver(InternetExplorerOptions)}
*/
@Deprecated
public InternetExplorerDriver(Capabilities capabilities) {
this(null, capabilities, DEFAULT_PORT);
this(null, capabilities);
}

public InternetExplorerDriver(InternetExplorerOptions options) {
this(null, options);
}

/**
* @deprecated Create an {@link InternetExplorerDriverService} and then use that to create a
* {@link RemoteWebDriver#RemoteWebDriver(org.openqa.selenium.remote.CommandExecutor, Capabilities)} with a
* {@link DriverCommandExecutor}.
*/
@Deprecated
public InternetExplorerDriver(int port) {
this(null, null, port);
}

public InternetExplorerDriver(InternetExplorerDriverService service) {
this(service, null, DEFAULT_PORT);
this(service, null);
}

/**
* @deprecated Use {@link #InternetExplorerDriver(InternetExplorerDriverService, InternetExplorerOptions)}
*/
@Deprecated
public InternetExplorerDriver(InternetExplorerDriverService service, Capabilities capabilities) {
this(service, capabilities, DEFAULT_PORT);
this(service, new InternetExplorerOptions(capabilities));
}

public InternetExplorerDriver(
InternetExplorerDriverService service,
InternetExplorerOptions options) {
this(service, options, DEFAULT_PORT);
}

/**
* @deprecated Create an {@link InternetExplorerDriverService} and then use that to create a
* {@link RemoteWebDriver#RemoteWebDriver(org.openqa.selenium.remote.CommandExecutor, Capabilities)} with a
* {@link DriverCommandExecutor}.
*/
@Deprecated
public InternetExplorerDriver(
InternetExplorerDriverService service,
Capabilities capabilities,
int port) {
if (capabilities == null) {
capabilities = DesiredCapabilities.internetExplorer();
if (options == null) {
options = new InternetExplorerOptions();
}

Preconditions.checkNotNull(capabilities);
capabilities = new InternetExplorerOptions(capabilities);

if (service == null) {
service = setupService(capabilities, port);
service = setupService(options);
}
run(service, capabilities);
run(service, options);
}

private void run(InternetExplorerDriverService service, Capabilities capabilities) {
Expand All @@ -237,9 +202,8 @@ protected void assertOnWindows() {
}
}

private InternetExplorerDriverService setupService(Capabilities caps, int port) {
private InternetExplorerDriverService setupService(Capabilities caps) {
InternetExplorerDriverService.Builder builder = new InternetExplorerDriverService.Builder();
builder.usingPort(port);

if (caps != null) {
if (caps.getCapability(LOG_FILE) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ public class InternetExplorerDriverService extends DriverService {
*/
public static final String IE_DRIVER_LOGLEVEL_PROPERTY = "webdriver.ie.driver.loglevel";

/**
* System property that defines the implementation of the driver engine to use.
*
* @deprecated There are no more multiple IE driver engines
*/
@Deprecated
public static final String IE_DRIVER_ENGINE_PROPERTY = "webdriver.ie.driver.engine";

/**
* System property that defines host to which will be bound IEDriverServer.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,6 @@ public InternetExplorerOptions introduceFlakinessByIgnoringSecurityDomains() {
return amend(INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
}

@Deprecated
public InternetExplorerOptions enableNativeEvents() {
return amend(NATIVE_EVENTS, true);
}

public InternetExplorerOptions disableNativeEvents() {
return amend(NATIVE_EVENTS, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static SafariDriverService createDefaultService() {
}

static SafariDriverService createDefaultService(SafariOptions options) {
return new Builder().usingTechnologyPreview(options.getUseTechnologyPreview()).build();
return new Builder().build();
}

static SafariDriverService createDefaultService(Capabilities caps) {
Expand Down
46 changes: 3 additions & 43 deletions java/client/src/org/openqa/selenium/safari/SafariOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.google.common.collect.ImmutableSortedMap;

import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.remote.AbstractDriverOptions;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriverException;
Expand Down Expand Up @@ -57,9 +58,6 @@ public class SafariOptions extends AbstractDriverOptions<SafariOptions> {
public static final String CAPABILITY = "safari.options";

private interface Option {
@Deprecated
String TECHNOLOGY_PREVIEW = "technologyPreview";

// Defined by Apple
String AUTOMATIC_INSPECTION = "safari:automaticInspection";
String AUTOMATIC_PROFILING = "safari:automaticProfiling";
Expand Down Expand Up @@ -110,7 +108,7 @@ public static SafariOptions fromCapabilities(Capabilities capabilities)
if (cap instanceof SafariOptions) {
return (SafariOptions) cap;
} else if (cap instanceof Map) {
return SafariOptions.fromJsonMap((Map<?, ?>) cap);
return new SafariOptions(new MutableCapabilities(((Map<String, ?>) cap)));
} else {
return new SafariOptions();
}
Expand Down Expand Up @@ -150,30 +148,11 @@ public SafariOptions setAutomaticProfiling(boolean automaticProfiling) {
* otherwise will use the release version of Safari.
*/
public SafariOptions setUseTechnologyPreview(boolean useTechnologyPreview) {
options.put(Option.TECHNOLOGY_PREVIEW, useTechnologyPreview);
// Use an object here, rather than a boolean to avoid a stack overflow
super.setCapability(BROWSER_NAME, useTechnologyPreview ? SAFARI_TECH_PREVIEW : "safari");
return this;
}

@Override
public void setCapability(String key, Object value) {
if (Option.TECHNOLOGY_PREVIEW.equals(key)) {
setUseTechnologyPreview(Boolean.valueOf(value.toString()));
} else {
super.setCapability(key, value);
}
}

@Override
public void setCapability(String key, boolean value) {
if (Option.TECHNOLOGY_PREVIEW.equals(key)) {
setUseTechnologyPreview(value);
} else {
super.setCapability(key, value);
}
}

// Getters

public boolean getAutomaticInspection() {
Expand All @@ -185,26 +164,7 @@ public boolean getAutomaticProfiling() {
}

public boolean getUseTechnologyPreview() {
return SAFARI_TECH_PREVIEW.equals(getBrowserName()) ||
options.get(Option.TECHNOLOGY_PREVIEW) == Boolean.TRUE;
}

// (De)serialization of the options

/**
* Parse a Map and reconstruct the {@link SafariOptions}.
*
* @return A {@link SafariOptions} instance associated with these extensions.
*/
private static SafariOptions fromJsonMap(Map<?, ?> options) {
SafariOptions safariOptions = new SafariOptions();

Object useTechnologyPreview = options.get(Option.TECHNOLOGY_PREVIEW);
if (useTechnologyPreview instanceof Boolean) {
safariOptions.setUseTechnologyPreview((Boolean) useTechnologyPreview);
}

return safariOptions;
return SAFARI_TECH_PREVIEW.equals(getBrowserName());
}

@Override
Expand Down

0 comments on commit 077f86f

Please sign in to comment.