diff --git a/gradle.properties b/gradle.properties index 10017f9d5..1bd7b6aed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ org.gradle.daemon=true -selenium.version=4.19.0 +selenium.version=4.26.0 # Please increment the value in a release appiumClient.version=9.3.0 diff --git a/src/main/java/io/appium/java_client/AppiumDriver.java b/src/main/java/io/appium/java_client/AppiumDriver.java index c8d660e9f..a8757843c 100644 --- a/src/main/java/io/appium/java_client/AppiumDriver.java +++ b/src/main/java/io/appium/java_client/AppiumDriver.java @@ -17,7 +17,6 @@ package io.appium.java_client; import io.appium.java_client.internal.CapabilityHelpers; -import io.appium.java_client.internal.ReflectionHelpers; import io.appium.java_client.internal.SessionHelpers; import io.appium.java_client.remote.AppiumCommandExecutor; import io.appium.java_client.remote.AppiumW3CHttpCommandCodec; @@ -27,7 +26,6 @@ import lombok.Getter; import org.openqa.selenium.Capabilities; import org.openqa.selenium.ImmutableCapabilities; -import org.openqa.selenium.MutableCapabilities; import org.openqa.selenium.OutputType; import org.openqa.selenium.SessionNotCreatedException; import org.openqa.selenium.UnsupportedCommandException; @@ -152,12 +150,10 @@ public AppiumDriver(Capabilities capabilities) { */ public AppiumDriver(URL remoteSessionAddress, String platformName, String automationName) { super(); - ReflectionHelpers.setPrivateFieldValue( - RemoteWebDriver.class, this, "capabilities", new ImmutableCapabilities( - Map.of( - PLATFORM_NAME, platformName, - APPIUM_PREFIX + AUTOMATION_NAME_OPTION, automationName - ) + this.capabilities = new ImmutableCapabilities( + Map.of( + PLATFORM_NAME, platformName, + APPIUM_PREFIX + AUTOMATION_NAME_OPTION, automationName ) ); SessionHelpers.SessionAddress sessionAddress = SessionHelpers.parseSessionAddress(remoteSessionAddress); @@ -168,7 +164,7 @@ public AppiumDriver(URL remoteSessionAddress, String platformName, String automa executor.setResponseCodec(new W3CHttpResponseCodec()); setCommandExecutor(executor); this.executeMethod = new AppiumExecutionMethod(this); - locationContext = new RemoteLocationContext(executeMethod); + this.locationContext = new RemoteLocationContext(executeMethod); super.setErrorHandler(ERROR_HANDLER); this.remoteAddress = executor.getAddressOfRemoteServer(); @@ -293,10 +289,7 @@ protected void startSession(Capabilities capabilities) { && isNullOrEmpty((String) rawCapabilities.get(CapabilityType.BROWSER_NAME))) { rawCapabilities.remove(CapabilityType.BROWSER_NAME); } - MutableCapabilities returnedCapabilities = new BaseOptions<>(rawCapabilities); - ReflectionHelpers.setPrivateFieldValue( - RemoteWebDriver.class, this, "capabilities", returnedCapabilities - ); + this.capabilities = new BaseOptions<>(rawCapabilities); setSessionId(response.getSessionId()); } @@ -345,8 +338,6 @@ public AppiumDriver markExtensionAbsence(String extName) { } protected HttpClient getHttpClient() { - return ReflectionHelpers.getPrivateFieldValue( - HttpCommandExecutor.class, getCommandExecutor(), "client", HttpClient.class - ); + return ((HttpCommandExecutor) getCommandExecutor()).client; } } diff --git a/src/main/java/io/appium/java_client/AppiumFluentWait.java b/src/main/java/io/appium/java_client/AppiumFluentWait.java index 6361a5652..a284e1ebb 100644 --- a/src/main/java/io/appium/java_client/AppiumFluentWait.java +++ b/src/main/java/io/appium/java_client/AppiumFluentWait.java @@ -17,7 +17,6 @@ package io.appium.java_client; import com.google.common.base.Throwables; -import io.appium.java_client.internal.ReflectionHelpers; import lombok.AccessLevel; import lombok.Getter; import org.openqa.selenium.TimeoutException; @@ -114,43 +113,32 @@ public AppiumFluentWait withPollDelay(Duration pollDelay) { return this; } - private B getPrivateFieldValue(String fieldName, Class fieldType) { - return ReflectionHelpers.getPrivateFieldValue(FluentWait.class, this, fieldName, fieldType); - } - - private Object getPrivateFieldValue(String fieldName) { - return getPrivateFieldValue(fieldName, Object.class); - } - protected Clock getClock() { - return getPrivateFieldValue("clock", Clock.class); + return clock; } protected Duration getTimeout() { - return getPrivateFieldValue("timeout", Duration.class); + return timeout; } protected Duration getInterval() { - return getPrivateFieldValue("interval", Duration.class); + return interval; } protected Sleeper getSleeper() { - return getPrivateFieldValue("sleeper", Sleeper.class); + return sleeper; } - @SuppressWarnings("unchecked") protected List> getIgnoredExceptions() { - return getPrivateFieldValue("ignoredExceptions", List.class); + return ignoredExceptions; } - @SuppressWarnings("unchecked") protected Supplier getMessageSupplier() { - return getPrivateFieldValue("messageSupplier", Supplier.class); + return messageSupplier; } - @SuppressWarnings("unchecked") protected T getInput() { - return (T) getPrivateFieldValue("input"); + return (T) input; } /** diff --git a/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java b/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java index 118f0ff81..a689e7d33 100644 --- a/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java +++ b/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java @@ -119,12 +119,14 @@ public AppiumCommandExecutor(Map additionalCommands, this(additionalCommands, service, HttpClient.Factory.createDefault(), appiumClientConfig); } + @Deprecated @SuppressWarnings("SameParameterValue") protected B getPrivateFieldValue( Class cls, String fieldName, Class fieldType) { return ReflectionHelpers.getPrivateFieldValue(cls, this, fieldName, fieldType); } + @Deprecated @SuppressWarnings("SameParameterValue") protected void setPrivateFieldValue( Class cls, String fieldName, Object newValue) { @@ -137,20 +139,19 @@ protected Map getAdditionalCommands() { } protected CommandCodec getCommandCodec() { - //noinspection unchecked - return getPrivateFieldValue(HttpCommandExecutor.class, "commandCodec", CommandCodec.class); + return this.commandCodec; } public void setCommandCodec(CommandCodec newCodec) { - setPrivateFieldValue(HttpCommandExecutor.class, "commandCodec", newCodec); + this.commandCodec = newCodec; } public void setResponseCodec(ResponseCodec codec) { - setPrivateFieldValue(HttpCommandExecutor.class, "responseCodec", codec); + this.responseCodec = codec; } protected HttpClient getClient() { - return getPrivateFieldValue(HttpCommandExecutor.class, "client", HttpClient.class); + return this.client; } /** diff --git a/src/main/java/io/appium/java_client/service/local/AppiumServiceBuilder.java b/src/main/java/io/appium/java_client/service/local/AppiumServiceBuilder.java index ad3729e77..5dadb6403 100644 --- a/src/main/java/io/appium/java_client/service/local/AppiumServiceBuilder.java +++ b/src/main/java/io/appium/java_client/service/local/AppiumServiceBuilder.java @@ -20,7 +20,6 @@ import com.google.gson.GsonBuilder; import io.appium.java_client.android.options.context.SupportsChromedriverExecutableOption; import io.appium.java_client.android.options.signing.SupportsKeystoreOptions; -import io.appium.java_client.internal.ReflectionHelpers; import io.appium.java_client.remote.MobileBrowserType; import io.appium.java_client.remote.options.SupportsAppOption; import io.appium.java_client.service.local.flags.GeneralServerFlag; @@ -400,10 +399,7 @@ protected List createArgs() { @Override protected void loadSystemProperties() { - File driverExecutable = ReflectionHelpers.getPrivateFieldValue( - DriverService.Builder.class, this, "exe", File.class - ); - if (driverExecutable == null) { + if (this.exe == null) { usingDriverExecutable(findDefaultExecutable()); } }