Skip to content

Commit a04691c

Browse files
chore: Bump the minimum java client version to 4.26.0
1 parent 1c58118 commit a04691c

File tree

5 files changed

+22
-46
lines changed

5 files changed

+22
-46
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
org.gradle.daemon=true
22

3-
selenium.version=4.19.0
3+
selenium.version=4.26.0
44
# Please increment the value in a release
55
appiumClient.version=9.3.0

src/main/java/io/appium/java_client/AppiumDriver.java

+7-16
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package io.appium.java_client;
1818

1919
import io.appium.java_client.internal.CapabilityHelpers;
20-
import io.appium.java_client.internal.ReflectionHelpers;
2120
import io.appium.java_client.internal.SessionHelpers;
2221
import io.appium.java_client.remote.AppiumCommandExecutor;
2322
import io.appium.java_client.remote.AppiumW3CHttpCommandCodec;
@@ -27,7 +26,6 @@
2726
import lombok.Getter;
2827
import org.openqa.selenium.Capabilities;
2928
import org.openqa.selenium.ImmutableCapabilities;
30-
import org.openqa.selenium.MutableCapabilities;
3129
import org.openqa.selenium.OutputType;
3230
import org.openqa.selenium.SessionNotCreatedException;
3331
import org.openqa.selenium.UnsupportedCommandException;
@@ -152,12 +150,10 @@ public AppiumDriver(Capabilities capabilities) {
152150
*/
153151
public AppiumDriver(URL remoteSessionAddress, String platformName, String automationName) {
154152
super();
155-
ReflectionHelpers.setPrivateFieldValue(
156-
RemoteWebDriver.class, this, "capabilities", new ImmutableCapabilities(
157-
Map.of(
158-
PLATFORM_NAME, platformName,
159-
APPIUM_PREFIX + AUTOMATION_NAME_OPTION, automationName
160-
)
153+
this.capabilities = new ImmutableCapabilities(
154+
Map.of(
155+
PLATFORM_NAME, platformName,
156+
APPIUM_PREFIX + AUTOMATION_NAME_OPTION, automationName
161157
)
162158
);
163159
SessionHelpers.SessionAddress sessionAddress = SessionHelpers.parseSessionAddress(remoteSessionAddress);
@@ -168,7 +164,7 @@ public AppiumDriver(URL remoteSessionAddress, String platformName, String automa
168164
executor.setResponseCodec(new W3CHttpResponseCodec());
169165
setCommandExecutor(executor);
170166
this.executeMethod = new AppiumExecutionMethod(this);
171-
locationContext = new RemoteLocationContext(executeMethod);
167+
this.locationContext = new RemoteLocationContext(executeMethod);
172168
super.setErrorHandler(ERROR_HANDLER);
173169
this.remoteAddress = executor.getAddressOfRemoteServer();
174170

@@ -293,10 +289,7 @@ protected void startSession(Capabilities capabilities) {
293289
&& isNullOrEmpty((String) rawCapabilities.get(CapabilityType.BROWSER_NAME))) {
294290
rawCapabilities.remove(CapabilityType.BROWSER_NAME);
295291
}
296-
MutableCapabilities returnedCapabilities = new BaseOptions<>(rawCapabilities);
297-
ReflectionHelpers.setPrivateFieldValue(
298-
RemoteWebDriver.class, this, "capabilities", returnedCapabilities
299-
);
292+
this.capabilities = new BaseOptions<>(rawCapabilities);
300293
setSessionId(response.getSessionId());
301294
}
302295

@@ -345,8 +338,6 @@ public AppiumDriver markExtensionAbsence(String extName) {
345338
}
346339

347340
protected HttpClient getHttpClient() {
348-
return ReflectionHelpers.getPrivateFieldValue(
349-
HttpCommandExecutor.class, getCommandExecutor(), "client", HttpClient.class
350-
);
341+
return ((HttpCommandExecutor) getCommandExecutor()).client;
351342
}
352343
}

src/main/java/io/appium/java_client/AppiumFluentWait.java

+7-19
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package io.appium.java_client;
1818

1919
import com.google.common.base.Throwables;
20-
import io.appium.java_client.internal.ReflectionHelpers;
2120
import lombok.AccessLevel;
2221
import lombok.Getter;
2322
import org.openqa.selenium.TimeoutException;
@@ -114,43 +113,32 @@ public AppiumFluentWait<T> withPollDelay(Duration pollDelay) {
114113
return this;
115114
}
116115

117-
private <B> B getPrivateFieldValue(String fieldName, Class<B> fieldType) {
118-
return ReflectionHelpers.getPrivateFieldValue(FluentWait.class, this, fieldName, fieldType);
119-
}
120-
121-
private Object getPrivateFieldValue(String fieldName) {
122-
return getPrivateFieldValue(fieldName, Object.class);
123-
}
124-
125116
protected Clock getClock() {
126-
return getPrivateFieldValue("clock", Clock.class);
117+
return clock;
127118
}
128119

129120
protected Duration getTimeout() {
130-
return getPrivateFieldValue("timeout", Duration.class);
121+
return timeout;
131122
}
132123

133124
protected Duration getInterval() {
134-
return getPrivateFieldValue("interval", Duration.class);
125+
return interval;
135126
}
136127

137128
protected Sleeper getSleeper() {
138-
return getPrivateFieldValue("sleeper", Sleeper.class);
129+
return sleeper;
139130
}
140131

141-
@SuppressWarnings("unchecked")
142132
protected List<Class<? extends Throwable>> getIgnoredExceptions() {
143-
return getPrivateFieldValue("ignoredExceptions", List.class);
133+
return ignoredExceptions;
144134
}
145135

146-
@SuppressWarnings("unchecked")
147136
protected Supplier<String> getMessageSupplier() {
148-
return getPrivateFieldValue("messageSupplier", Supplier.class);
137+
return messageSupplier;
149138
}
150139

151-
@SuppressWarnings("unchecked")
152140
protected T getInput() {
153-
return (T) getPrivateFieldValue("input");
141+
return (T) input;
154142
}
155143

156144
/**

src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
119119
this(additionalCommands, service, HttpClient.Factory.createDefault(), appiumClientConfig);
120120
}
121121

122+
@Deprecated
122123
@SuppressWarnings("SameParameterValue")
123124
protected <B> B getPrivateFieldValue(
124125
Class<? extends CommandExecutor> cls, String fieldName, Class<B> fieldType) {
125126
return ReflectionHelpers.getPrivateFieldValue(cls, this, fieldName, fieldType);
126127
}
127128

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

139141
protected CommandCodec<HttpRequest> getCommandCodec() {
140-
//noinspection unchecked
141-
return getPrivateFieldValue(HttpCommandExecutor.class, "commandCodec", CommandCodec.class);
142+
return this.commandCodec;
142143
}
143144

144145
public void setCommandCodec(CommandCodec<HttpRequest> newCodec) {
145-
setPrivateFieldValue(HttpCommandExecutor.class, "commandCodec", newCodec);
146+
this.commandCodec = newCodec;
146147
}
147148

148149
public void setResponseCodec(ResponseCodec<HttpResponse> codec) {
149-
setPrivateFieldValue(HttpCommandExecutor.class, "responseCodec", codec);
150+
this.responseCodec = codec;
150151
}
151152

152153
protected HttpClient getClient() {
153-
return getPrivateFieldValue(HttpCommandExecutor.class, "client", HttpClient.class);
154+
return this.client;
154155
}
155156

156157
/**

src/main/java/io/appium/java_client/service/local/AppiumServiceBuilder.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.google.gson.GsonBuilder;
2121
import io.appium.java_client.android.options.context.SupportsChromedriverExecutableOption;
2222
import io.appium.java_client.android.options.signing.SupportsKeystoreOptions;
23-
import io.appium.java_client.internal.ReflectionHelpers;
2423
import io.appium.java_client.remote.MobileBrowserType;
2524
import io.appium.java_client.remote.options.SupportsAppOption;
2625
import io.appium.java_client.service.local.flags.GeneralServerFlag;
@@ -400,10 +399,7 @@ protected List<String> createArgs() {
400399

401400
@Override
402401
protected void loadSystemProperties() {
403-
File driverExecutable = ReflectionHelpers.getPrivateFieldValue(
404-
DriverService.Builder.class, this, "exe", File.class
405-
);
406-
if (driverExecutable == null) {
402+
if (this.exe == null) {
407403
usingDriverExecutable(findDefaultExecutable());
408404
}
409405
}

0 commit comments

Comments
 (0)