Skip to content

Commit 31ce398

Browse files
author
汪啸
committed
fix element timeout changing page object timeout issue
1 parent ef779eb commit 31ce398

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class AppiumElementLocator implements CacheableLocator {
4242
final boolean shouldCache;
4343
final By by;
4444
final TimeOutDuration timeOutDuration;
45+
private final TimeOutDuration originalTimeOutDuration;
4546
final WebDriver originalWebDriver;
4647
private final SearchContext searchContext;
4748
private final WaitingFunction waitingFunction;
@@ -56,16 +57,18 @@ class AppiumElementLocator implements CacheableLocator {
5657
* @param by a By locator strategy
5758
* @param shouldCache is the flag that signalizes that elements which
5859
* are found once should be cached
59-
* @param duration is a POJO which contains timeout parameters
60+
* @param duration is a POJO which contains timeout parameters for the element to be searched
61+
* @param originalDuration is a POJO which contains timeout parameters from page object which contains the element
6062
* @param originalWebDriver is an instance of WebDriver that is going to be
6163
* used by a proxied element
6264
*/
6365

6466
public AppiumElementLocator(SearchContext searchContext, By by, boolean shouldCache,
65-
TimeOutDuration duration, WebDriver originalWebDriver) {
67+
TimeOutDuration duration, TimeOutDuration originalDuration, WebDriver originalWebDriver) {
6668
this.searchContext = searchContext;
6769
this.shouldCache = shouldCache;
6870
this.timeOutDuration = duration;
71+
this.originalTimeOutDuration = originalDuration;
6972
this.by = by;
7073
this.originalWebDriver = originalWebDriver;
7174
waitingFunction = new WaitingFunction(this.searchContext);
@@ -89,7 +92,7 @@ private List<WebElement> waitFor() {
8992
} catch (TimeoutException e) {
9093
return new ArrayList<>();
9194
} finally {
92-
changeImplicitlyWaitTimeOut(timeOutDuration.getTime(), timeOutDuration.getTimeUnit());
95+
changeImplicitlyWaitTimeOut(originalTimeOutDuration.getTime(), originalTimeOutDuration.getTimeUnit());
9396
}
9497
}
9598

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public CacheableLocator createLocator(Field field) {
5757
By by = builder.buildBy();
5858
if (by != null) {
5959
return new AppiumElementLocator(searchContext, by, builder.isLookupCached(),
60-
customDuration, originalWebDriver);
60+
customDuration, timeOutDuration, originalWebDriver);
6161
}
6262
return null;
6363
}

0 commit comments

Comments
 (0)