diff --git a/java/spotbugs-excludes.xml b/java/spotbugs-excludes.xml index a1104b7f597b6..9c584772c8696 100644 --- a/java/spotbugs-excludes.xml +++ b/java/spotbugs-excludes.xml @@ -139,12 +139,7 @@ - - - - - - + diff --git a/java/src/org/openqa/selenium/BUILD.bazel b/java/src/org/openqa/selenium/BUILD.bazel index a10ac67d52a0f..cec50c2485fec 100644 --- a/java/src/org/openqa/selenium/BUILD.bazel +++ b/java/src/org/openqa/selenium/BUILD.bazel @@ -17,7 +17,6 @@ java_export( "internal/*.java", "interactions/**/*.java", "logging/**/*.java", - "mobile/*.java", "net/*.java", "virtualauthenticator/*.java", "print/*.java", diff --git a/java/src/org/openqa/selenium/chromium/ChromiumDriver.java b/java/src/org/openqa/selenium/chromium/ChromiumDriver.java index b5f6dacb3a7bb..37accd0c3dafb 100644 --- a/java/src/org/openqa/selenium/chromium/ChromiumDriver.java +++ b/java/src/org/openqa/selenium/chromium/ChromiumDriver.java @@ -61,7 +61,6 @@ import org.openqa.selenium.json.TypeToken; import org.openqa.selenium.logging.EventType; import org.openqa.selenium.logging.HasLogEvents; -import org.openqa.selenium.mobile.NetworkConnection; import org.openqa.selenium.remote.CommandExecutor; import org.openqa.selenium.remote.FileDetector; import org.openqa.selenium.remote.RemoteWebDriver; @@ -70,7 +69,6 @@ import org.openqa.selenium.remote.http.ClientConfig; import org.openqa.selenium.remote.http.ConnectionFailedException; import org.openqa.selenium.remote.http.HttpClient; -import org.openqa.selenium.remote.mobile.RemoteNetworkConnection; /** * A {@link WebDriver} implementation that controls a Chromium browser running on the local machine. @@ -87,7 +85,6 @@ public class ChromiumDriver extends RemoteWebDriver HasNetworkConditions, HasPermissions, LocationContext, - NetworkConnection, WebStorage { public static final Predicate IS_CHROMIUM_BROWSER = @@ -97,7 +94,6 @@ public class ChromiumDriver extends RemoteWebDriver private final Capabilities capabilities; private final RemoteLocationContext locationContext; private final RemoteWebStorage webStorage; - private final RemoteNetworkConnection networkConnection; private final HasNetworkConditions networkConditions; private final HasPermissions permissions; private final HasLaunchApp launch; @@ -115,7 +111,6 @@ protected ChromiumDriver( locationContext = new RemoteLocationContext(getExecuteMethod()); webStorage = new RemoteWebStorage(getExecuteMethod()); permissions = new AddHasPermissions().getImplementation(getCapabilities(), getExecuteMethod()); - networkConnection = new RemoteNetworkConnection(getExecuteMethod()); networkConditions = new AddHasNetworkConditions().getImplementation(getCapabilities(), getExecuteMethod()); launch = new AddHasLaunchApp().getImplementation(getCapabilities(), getExecuteMethod()); @@ -317,19 +312,6 @@ public void setLocation(Location location) { locationContext.setLocation(location); } - @Override - @Deprecated - public ConnectionType getNetworkConnection() { - return networkConnection.getNetworkConnection(); - } - - @Override - @Deprecated - public ConnectionType setNetworkConnection(ConnectionType type) { - Require.nonNull("Network Connection Type", type); - return networkConnection.setNetworkConnection(type); - } - @Override public void launchApp(String id) { Require.nonNull("Launch App ID", id); diff --git a/java/src/org/openqa/selenium/mobile/NetworkConnection.java b/java/src/org/openqa/selenium/mobile/NetworkConnection.java deleted file mode 100644 index 1dda98d47275a..0000000000000 --- a/java/src/org/openqa/selenium/mobile/NetworkConnection.java +++ /dev/null @@ -1,136 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.mobile; - -/** - * Control a device's network connection - * - *

Example usage: - * - *

- * NetworkConnection mobileDriver = (NetworkConnection) driver;
- * if (mobileDriver.getNetworkConnection() != ConnectionType.AIRPLANE_MODE) {
- *   // enabling Airplane mode
- *   mobileDriver.setNetworkConnection(ConnectionType.AIRPLANE_MODE);
- * }
- * 
- */ -@Deprecated -public interface NetworkConnection { - - /** - * ConnectionType is a bitmask to represent a device's network connection - * - *
-   * Data  | WIFI | Airplane
-   * 0       0      1         == 1
-   * 1       1      0         == 6
-   * 1       0      0         == 4
-   * 0       1      0         == 2
-   * 0       0      0         == 0
-   * 
- * - *

Giving "Data" the first bit positions in order to give room for the future of enabling - * specific types of data (Edge / 2G, 3G, 4G, LTE, etc) if the device allows it. - */ - class ConnectionType { - - public static final ConnectionType WIFI = new ConnectionType(2); - public static final ConnectionType DATA = new ConnectionType(4); - public static final ConnectionType AIRPLANE_MODE = new ConnectionType(1); - public static final ConnectionType ALL = new ConnectionType(6); - public static final ConnectionType NONE = new ConnectionType(0); - - /* - Future for Network Data types. With a new constructor accepting this enum. - public enum DataType { - _2G, _3G, _4G, LTE - } - */ - - private int mask = 0; - - public ConnectionType(Boolean wifi, Boolean data, Boolean airplaneMode) { - if (wifi) { - mask += WIFI.mask; - } - if (data) { - mask += DATA.mask; - } - if (airplaneMode) { - mask += AIRPLANE_MODE.mask; - } - } - - public ConnectionType(int mask) { - // must be a positive number - this.mask = Math.max(mask, 0); - } - - public Boolean isAirplaneMode() { - return mask % 2 == 1; - } - - public Boolean isWifiEnabled() { - // shift right 1 bit, check last bit - return (mask / 2) % 2 == 1; - } - - public Boolean isDataEnabled() { - // shift right 2 bits, check if any bits set - return (mask / 4) > 0; - } - - @Override - public boolean equals(Object type) { - return type instanceof ConnectionType && this.mask == ((ConnectionType) type).mask; - } - - @Override - public int hashCode() { - return mask; - } - - @Override - public String toString() { - return Integer.toString(mask); - } - - public Integer toJson() { - return mask; - } - } - - /** - * Query the driver for the Airplane Mode setting state - * - * @return {@link org.openqa.selenium.mobile.NetworkConnection.ConnectionType} indicating if the - * device is in Airplane Mode - */ - ConnectionType getNetworkConnection(); - - /** - * Set the Connection type Not all connection type combinations are valid for an individual type - * of device and the remote endpoint will make a best effort to set the type as requested - * - * @param type ConnectionType of what the network connection should be - * @return {@link org.openqa.selenium.mobile.NetworkConnection.ConnectionType} of what the - * device's network connection is - */ - ConnectionType setNetworkConnection(ConnectionType type); -} diff --git a/java/src/org/openqa/selenium/remote/DriverCommand.java b/java/src/org/openqa/selenium/remote/DriverCommand.java index 18da731775c1a..5ee279bfc747a 100644 --- a/java/src/org/openqa/selenium/remote/DriverCommand.java +++ b/java/src/org/openqa/selenium/remote/DriverCommand.java @@ -136,9 +136,6 @@ public interface DriverCommand { // Logging API String GET_AVAILABLE_LOG_TYPES = "getAvailableLogTypes"; String GET_LOG = "getLog"; - // Mobile API - String GET_NETWORK_CONNECTION = "getNetworkConnection"; - String SET_NETWORK_CONNECTION = "setNetworkConnection"; // Virtual Authenticator API // http://w3c.github.io/webauthn#sctn-automation String ADD_VIRTUAL_AUTHENTICATOR = "addVirtualAuthenticator"; diff --git a/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java b/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java index 1f73cbca58b46..df6318a11ed14 100644 --- a/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java +++ b/java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java @@ -53,7 +53,6 @@ import static org.openqa.selenium.remote.DriverCommand.GET_FEDCM_DIALOG_TYPE; import static org.openqa.selenium.remote.DriverCommand.GET_FEDCM_TITLE; import static org.openqa.selenium.remote.DriverCommand.GET_LOCATION; -import static org.openqa.selenium.remote.DriverCommand.GET_NETWORK_CONNECTION; import static org.openqa.selenium.remote.DriverCommand.GET_TIMEOUTS; import static org.openqa.selenium.remote.DriverCommand.GET_TITLE; import static org.openqa.selenium.remote.DriverCommand.GO_BACK; @@ -73,7 +72,6 @@ import static org.openqa.selenium.remote.DriverCommand.SEND_KEYS_TO_ELEMENT; import static org.openqa.selenium.remote.DriverCommand.SET_DELAY_ENABLED; import static org.openqa.selenium.remote.DriverCommand.SET_LOCATION; -import static org.openqa.selenium.remote.DriverCommand.SET_NETWORK_CONNECTION; import static org.openqa.selenium.remote.DriverCommand.SET_SCRIPT_TIMEOUT; import static org.openqa.selenium.remote.DriverCommand.SET_TIMEOUT; import static org.openqa.selenium.remote.DriverCommand.SET_USER_VERIFIED; @@ -177,14 +175,6 @@ public AbstractHttpCommandCodec() { defineCommand( SET_LOCATION, post(sessionId + "/location")); // Not w3c; used in RemoteLocationContext - // Mobile Spec - defineCommand( - GET_NETWORK_CONNECTION, - get(sessionId + "/network_connection")); // Not w3c; used in RemoteNetworkConnection - defineCommand( - SET_NETWORK_CONNECTION, - post(sessionId + "/network_connection")); // Not w3c; used in RemoteNetworkConnection - // Virtual Authenticator API String webauthn = sessionId + "/webauthn/authenticator"; String webauthnId = webauthn + "/:authenticatorId"; diff --git a/java/src/org/openqa/selenium/remote/mobile/RemoteNetworkConnection.java b/java/src/org/openqa/selenium/remote/mobile/RemoteNetworkConnection.java deleted file mode 100644 index c4efa117931fd..0000000000000 --- a/java/src/org/openqa/selenium/remote/mobile/RemoteNetworkConnection.java +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.remote.mobile; - -import java.util.Map; -import org.openqa.selenium.mobile.NetworkConnection; -import org.openqa.selenium.remote.DriverCommand; -import org.openqa.selenium.remote.ExecuteMethod; - -/** - * @deprecated This functionality is no longer supported - */ -@Deprecated -public class RemoteNetworkConnection implements NetworkConnection { - - private final ExecuteMethod executeMethod; - - public RemoteNetworkConnection(ExecuteMethod executeMethod) { - this.executeMethod = executeMethod; - } - - @Override - @Deprecated - public ConnectionType getNetworkConnection() { - return new ConnectionType( - ((Number) executeMethod.execute(DriverCommand.GET_NETWORK_CONNECTION, null)).intValue()); - } - - @Override - @Deprecated - public ConnectionType setNetworkConnection(ConnectionType type) { - Map mode = Map.of("type", type); - return new ConnectionType( - ((Number) - executeMethod.execute( - DriverCommand.SET_NETWORK_CONNECTION, Map.of("parameters", mode))) - .intValue()); - } -} diff --git a/java/test/org/openqa/selenium/mobile/BUILD.bazel b/java/test/org/openqa/selenium/mobile/BUILD.bazel deleted file mode 100644 index 7505aae40aa60..0000000000000 --- a/java/test/org/openqa/selenium/mobile/BUILD.bazel +++ /dev/null @@ -1,18 +0,0 @@ -load("@rules_jvm_external//:defs.bzl", "artifact") -load("//java:defs.bzl", "JUNIT5_DEPS", "java_selenium_test_suite") - -java_selenium_test_suite( - name = "large-tests", - size = "large", - srcs = glob(["*.java"]), - browsers = [ - "firefox", - ], - deps = [ - "//java/src/org/openqa/selenium/remote", - "//java/test/org/openqa/selenium/testing:annotations", - "//java/test/org/openqa/selenium/testing:test-base", - artifact("org.junit.jupiter:junit-jupiter-api"), - artifact("org.assertj:assertj-core"), - ] + JUNIT5_DEPS, -) diff --git a/java/test/org/openqa/selenium/mobile/NetworkConnectionTest.java b/java/test/org/openqa/selenium/mobile/NetworkConnectionTest.java deleted file mode 100644 index d4fffe6d9c888..0000000000000 --- a/java/test/org/openqa/selenium/mobile/NetworkConnectionTest.java +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.selenium.mobile; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assumptions.assumeTrue; -import static org.openqa.selenium.testing.drivers.Browser.CHROME; -import static org.openqa.selenium.testing.drivers.Browser.EDGE; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.remote.Augmenter; -import org.openqa.selenium.testing.JupiterTestBase; -import org.openqa.selenium.testing.NotYetImplemented; - -class NetworkConnectionTest extends JupiterTestBase { - - private NetworkConnection networkConnectionDriver; - - @BeforeEach - public void setUp() { - WebDriver augmented = new Augmenter().augment(driver); - assumeTrue(augmented instanceof NetworkConnection); - networkConnectionDriver = (NetworkConnection) augmented; - } - - @Test - @NotYetImplemented(CHROME) - @NotYetImplemented(EDGE) - public void testToggleAirplaneMode() { - NetworkConnection.ConnectionType current = networkConnectionDriver.getNetworkConnection(); - NetworkConnection.ConnectionType modified; - if (current.isAirplaneMode()) { - modified = networkConnectionDriver.setNetworkConnection(NetworkConnection.ConnectionType.ALL); - } else { - modified = - networkConnectionDriver.setNetworkConnection( - NetworkConnection.ConnectionType.AIRPLANE_MODE); - } - assertThat(modified.isAirplaneMode()) - .describedAs("airplane mode should have been toggled") - .isNotEqualTo(current.isAirplaneMode()); - } -}