diff --git a/src/main/java/io/appium/java_client/pagefactory/AppiumElementLocator.java b/src/main/java/io/appium/java_client/pagefactory/AppiumElementLocator.java index 5ccfdb093..eb11f441c 100644 --- a/src/main/java/io/appium/java_client/pagefactory/AppiumElementLocator.java +++ b/src/main/java/io/appium/java_client/pagefactory/AppiumElementLocator.java @@ -42,6 +42,7 @@ class AppiumElementLocator implements CacheableLocator { final boolean shouldCache; final By by; final TimeOutDuration timeOutDuration; + private final TimeOutDuration originalTimeOutDuration; final WebDriver originalWebDriver; private final SearchContext searchContext; private final WaitingFunction waitingFunction; @@ -56,16 +57,18 @@ class AppiumElementLocator implements CacheableLocator { * @param by a By locator strategy * @param shouldCache is the flag that signalizes that elements which * are found once should be cached - * @param duration is a POJO which contains timeout parameters + * @param duration is a POJO which contains timeout parameters for the element to be searched + * @param originalDuration is a POJO which contains timeout parameters from page object which contains the element * @param originalWebDriver is an instance of WebDriver that is going to be * used by a proxied element */ public AppiumElementLocator(SearchContext searchContext, By by, boolean shouldCache, - TimeOutDuration duration, WebDriver originalWebDriver) { + TimeOutDuration duration, TimeOutDuration originalDuration, WebDriver originalWebDriver) { this.searchContext = searchContext; this.shouldCache = shouldCache; this.timeOutDuration = duration; + this.originalTimeOutDuration = originalDuration; this.by = by; this.originalWebDriver = originalWebDriver; waitingFunction = new WaitingFunction(this.searchContext); @@ -89,7 +92,7 @@ private List waitFor() { } catch (TimeoutException e) { return new ArrayList<>(); } finally { - changeImplicitlyWaitTimeOut(timeOutDuration.getTime(), timeOutDuration.getTimeUnit()); + changeImplicitlyWaitTimeOut(originalTimeOutDuration.getTime(), originalTimeOutDuration.getTimeUnit()); } } diff --git a/src/main/java/io/appium/java_client/pagefactory/AppiumElementLocatorFactory.java b/src/main/java/io/appium/java_client/pagefactory/AppiumElementLocatorFactory.java index fa13938e1..1b9c8ebe1 100644 --- a/src/main/java/io/appium/java_client/pagefactory/AppiumElementLocatorFactory.java +++ b/src/main/java/io/appium/java_client/pagefactory/AppiumElementLocatorFactory.java @@ -57,7 +57,7 @@ public CacheableLocator createLocator(Field field) { By by = builder.buildBy(); if (by != null) { return new AppiumElementLocator(searchContext, by, builder.isLookupCached(), - customDuration, originalWebDriver); + customDuration, timeOutDuration, originalWebDriver); } return null; }