Skip to content

Commit 24cec01

Browse files
valfirstSrinivasanTarget
authored andcommitted
Upgrade to Selenium 3.14.0 (appium#992)
1 parent 8af9d2b commit 24cec01

File tree

14 files changed

+31
-132
lines changed

14 files changed

+31
-132
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ compileJava {
5050
]
5151
}
5252

53-
ext.seleniumVersion = '3.13.0'
53+
ext.seleniumVersion = '3.14.0'
5454

5555
dependencies {
5656
compile ("org.seleniumhq.selenium:selenium-java:${seleniumVersion}") {

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@
1616

1717
package io.appium.java_client;
1818

19-
import static java.time.Duration.ofMillis;
20-
2119
import com.google.common.base.Throwables;
2220

2321
import org.openqa.selenium.TimeoutException;
2422
import org.openqa.selenium.WebDriverException;
25-
import org.openqa.selenium.support.ui.Clock;
2623
import org.openqa.selenium.support.ui.FluentWait;
2724
import org.openqa.selenium.support.ui.Sleeper;
2825

2926
import java.lang.reflect.Field;
27+
import java.time.Clock;
3028
import java.time.Duration;
29+
import java.time.Instant;
3130
import java.util.List;
3231
import java.util.function.Function;
3332
import java.util.function.Supplier;
@@ -228,8 +227,8 @@ public AppiumFluentWait<T> withPollingStrategy(Function<IterationInfo, Duration>
228227
*/
229228
@Override
230229
public <V> V until(Function<? super T, V> isTrue) {
231-
final long start = getClock().now();
232-
final long end = getClock().laterBy(getTimeout().toMillis());
230+
final Instant start = getClock().instant();
231+
final Instant end = getClock().instant().plus(getTimeout());
233232
long iterationNumber = 1;
234233
Throwable lastException;
235234
while (true) {
@@ -249,7 +248,7 @@ public <V> V until(Function<? super T, V> isTrue) {
249248

250249
// Check the timeout after evaluating the function to ensure conditions
251250
// with a zero timeout can succeed.
252-
if (!getClock().isNowBefore(end)) {
251+
if (end.isBefore(getClock().instant())) {
253252
String message = getMessageSupplier() != null ? getMessageSupplier().get() : null;
254253

255254
String timeoutMessage = String.format(
@@ -263,7 +262,7 @@ public <V> V until(Function<? super T, V> isTrue) {
263262
Duration interval = getInterval();
264263
if (pollingStrategy != null) {
265264
final IterationInfo info = new IterationInfo(iterationNumber,
266-
ofMillis(getClock().now() - start), getTimeout(),
265+
Duration.between(start, getClock().instant()), getTimeout(),
267266
interval);
268267
interval = pollingStrategy.apply(info);
269268
}

src/main/java/io/appium/java_client/android/AndroidMobileCommandHelper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import io.appium.java_client.MobileCommand;
2424

2525
import org.apache.commons.lang3.StringUtils;
26-
import org.openqa.selenium.internal.HasIdentity;
26+
import org.openqa.selenium.remote.RemoteWebElement;
2727

2828
import java.util.AbstractMap;
2929
import java.util.Map;
@@ -267,15 +267,15 @@ public class AndroidMobileCommandHelper extends MobileCommand {
267267
* This method forms a {@link Map} of parameters for the element
268268
* value replacement. It is used against input elements
269269
*
270-
* @param hasIdentityObject an instance which contains an element ID
270+
* @param remoteWebElement an instance which contains an element ID
271271
* @param value a new value
272272
* @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
273273
*/
274274
public static Map.Entry<String, Map<String, ?>> replaceElementValueCommand(
275-
HasIdentity hasIdentityObject, String value) {
275+
RemoteWebElement remoteWebElement, String value) {
276276
String[] parameters = new String[] {"id", "value"};
277277
Object[] values =
278-
new Object[] {hasIdentityObject.getId(), value};
278+
new Object[] {remoteWebElement.getId(), value};
279279

280280
return new AbstractMap.SimpleEntry<>(
281281
REPLACE_VALUE, prepareArguments(parameters, values));

src/main/java/io/appium/java_client/pagefactory/Widget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.openqa.selenium.SearchContext;
2323
import org.openqa.selenium.WebDriver;
2424
import org.openqa.selenium.WebElement;
25-
import org.openqa.selenium.internal.WrapsDriver;
25+
import org.openqa.selenium.WrapsDriver;
2626
import org.openqa.selenium.internal.WrapsElement;
2727

2828
import java.util.List;

src/main/java/io/appium/java_client/pagefactory/interceptors/InterceptorOfASingleElement.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@
2020
import net.sf.cglib.proxy.MethodProxy;
2121
import org.openqa.selenium.WebDriver;
2222
import org.openqa.selenium.WebElement;
23-
import org.openqa.selenium.internal.WrapsDriver;
23+
import org.openqa.selenium.WrapsDriver;
2424
import org.openqa.selenium.support.pagefactory.ElementLocator;
2525

2626
import java.lang.reflect.Method;
2727

28-
2928
public abstract class InterceptorOfASingleElement implements MethodInterceptor {
3029
protected final ElementLocator locator;
3130
protected final WebDriver driver;

src/main/java/io/appium/java_client/pagefactory/utils/WebDriverUnpackUtility.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.openqa.selenium.ContextAware;
2727
import org.openqa.selenium.SearchContext;
2828
import org.openqa.selenium.WebDriver;
29-
import org.openqa.selenium.internal.WrapsDriver;
29+
import org.openqa.selenium.WrapsDriver;
3030
import org.openqa.selenium.internal.WrapsElement;
3131

3232
public final class WebDriverUnpackUtility {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
8989

9090
public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
9191
URL addressOfRemoteServer) {
92-
this(additionalCommands, addressOfRemoteServer, new AppiumHttpClientFactory());
92+
this(additionalCommands, addressOfRemoteServer, HttpClient.Factory.createDefault());
9393
}
9494

9595
public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
9696
DriverService service) {
97-
this(additionalCommands, service, new AppiumHttpClientFactory());
97+
this(additionalCommands, service, HttpClient.Factory.createDefault());
9898
}
9999

100100
protected <B> B getPrivateFieldValue(String fieldName, Class<B> fieldType) {

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

Lines changed: 0 additions & 99 deletions
This file was deleted.

src/main/java/io/appium/java_client/touch/offset/ElementOption.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import org.openqa.selenium.Point;
88
import org.openqa.selenium.WebElement;
9-
import org.openqa.selenium.internal.HasIdentity;
9+
import org.openqa.selenium.remote.RemoteWebElement;
1010

1111
import java.util.HashMap;
1212
import java.util.Map;
@@ -60,9 +60,9 @@ public ElementOption withCoordinates(int xOffset, int yOffset) {
6060
public ElementOption withElement(WebElement element) {
6161
checkNotNull(element);
6262
checkArgument(true, "Element should be an instance of the class which "
63-
+ "implements org.openqa.selenium.internal.HasIdentity",
64-
(HasIdentity.class.isAssignableFrom(element.getClass())));
65-
elementId = HasIdentity.class.cast(element).getId();
63+
+ "extends org.openqa.selenium.remote.RemoteWebElement",
64+
(RemoteWebElement.class.isAssignableFrom(element.getClass())));
65+
elementId = RemoteWebElement.class.cast(element).getId();
6666
return this;
6767
}
6868

src/test/java/io/appium/java_client/appium/AppiumFluentWaitTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
import org.junit.Assert;
2727
import org.junit.Test;
2828
import org.openqa.selenium.TimeoutException;
29-
import org.openqa.selenium.support.ui.SystemClock;
3029
import org.openqa.selenium.support.ui.Wait;
3130

31+
import java.time.Clock;
3232
import java.util.concurrent.atomic.AtomicInteger;
3333
import java.util.function.Function;
3434

@@ -43,7 +43,7 @@ public boolean isDisplayed() {
4343
@Test(expected = TimeoutException.class)
4444
public void testDefaultStrategy() {
4545
final FakeElement el = new FakeElement();
46-
final Wait<FakeElement> wait = new AppiumFluentWait<>(el, new SystemClock(), duration -> {
46+
final Wait<FakeElement> wait = new AppiumFluentWait<>(el, Clock.systemDefaultZone(), duration -> {
4747
assertThat(duration.getSeconds(), is(equalTo(1L)));
4848
Thread.sleep(duration.toMillis());
4949
}).withPollingStrategy(AppiumFluentWait.IterationInfo::getInterval)
@@ -57,7 +57,7 @@ public void testDefaultStrategy() {
5757
public void testCustomStrategyOverridesDefaultInterval() {
5858
final FakeElement el = new FakeElement();
5959
final AtomicInteger callsCounter = new AtomicInteger(0);
60-
final Wait<FakeElement> wait = new AppiumFluentWait<>(el, new SystemClock(), duration -> {
60+
final Wait<FakeElement> wait = new AppiumFluentWait<>(el, Clock.systemDefaultZone(), duration -> {
6161
callsCounter.incrementAndGet();
6262
assertThat(duration.getSeconds(), is(equalTo(2L)));
6363
Thread.sleep(duration.toMillis());
@@ -79,7 +79,7 @@ public void testIntervalCalculationForCustomStrategy() {
7979
final AtomicInteger callsCounter = new AtomicInteger(0);
8080
// Linear dependency
8181
final Function<Long, Long> pollingStrategy = x -> x * 2;
82-
final Wait<FakeElement> wait = new AppiumFluentWait<>(el, new SystemClock(), duration -> {
82+
final Wait<FakeElement> wait = new AppiumFluentWait<>(el, Clock.systemDefaultZone(), duration -> {
8383
int callNumber = callsCounter.incrementAndGet();
8484
assertThat(duration.getSeconds(), is(equalTo(pollingStrategy.apply((long) callNumber))));
8585
Thread.sleep(duration.toMillis());

0 commit comments

Comments
 (0)