Skip to content

Commit

Permalink
chore: Bump the minimum java client version to 4.26.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach committed Nov 26, 2024
1 parent 1c58118 commit a04691c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 46 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
23 changes: 7 additions & 16 deletions src/main/java/io/appium/java_client/AppiumDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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();

Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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;
}
}
26 changes: 7 additions & 19 deletions src/main/java/io/appium/java_client/AppiumFluentWait.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -114,43 +113,32 @@ public AppiumFluentWait<T> withPollDelay(Duration pollDelay) {
return this;
}

private <B> B getPrivateFieldValue(String fieldName, Class<B> 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<Class<? extends Throwable>> getIgnoredExceptions() {
return getPrivateFieldValue("ignoredExceptions", List.class);
return ignoredExceptions;
}

@SuppressWarnings("unchecked")
protected Supplier<String> getMessageSupplier() {
return getPrivateFieldValue("messageSupplier", Supplier.class);
return messageSupplier;
}

@SuppressWarnings("unchecked")
protected T getInput() {
return (T) getPrivateFieldValue("input");
return (T) input;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
this(additionalCommands, service, HttpClient.Factory.createDefault(), appiumClientConfig);
}

@Deprecated
@SuppressWarnings("SameParameterValue")
protected <B> B getPrivateFieldValue(
Class<? extends CommandExecutor> cls, String fieldName, Class<B> fieldType) {
return ReflectionHelpers.getPrivateFieldValue(cls, this, fieldName, fieldType);
}

@Deprecated
@SuppressWarnings("SameParameterValue")
protected void setPrivateFieldValue(
Class<? extends CommandExecutor> cls, String fieldName, Object newValue) {
Expand All @@ -137,20 +139,19 @@ protected Map<String, CommandInfo> getAdditionalCommands() {
}

protected CommandCodec<HttpRequest> getCommandCodec() {
//noinspection unchecked
return getPrivateFieldValue(HttpCommandExecutor.class, "commandCodec", CommandCodec.class);
return this.commandCodec;
}

public void setCommandCodec(CommandCodec<HttpRequest> newCodec) {
setPrivateFieldValue(HttpCommandExecutor.class, "commandCodec", newCodec);
this.commandCodec = newCodec;
}

public void setResponseCodec(ResponseCodec<HttpResponse> codec) {
setPrivateFieldValue(HttpCommandExecutor.class, "responseCodec", codec);
this.responseCodec = codec;
}

protected HttpClient getClient() {
return getPrivateFieldValue(HttpCommandExecutor.class, "client", HttpClient.class);
return this.client;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -400,10 +399,7 @@ protected List<String> 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());
}
}
Expand Down

0 comments on commit a04691c

Please sign in to comment.