appium/java-client

page object pattern, field with "@WithTimeout" would change the global implicit wait time

truebit opened this issue · 2 comments

Description

page object pattern, field with "@WithTimeout" would change the global implicit wait time

Environment

Always exists. see code analysis below

Details

in method AppiumElementLocatorFactory#createLocator:

  • if the page object field contains annoation WithTimeout, it would create a new TimeOutDuration instance.
  • This instance would be passed to AppiumElementLocator.
  • When element tries to find the element. It would invoke method AppiumElementLocator#waitFor. See the line in finally block. it would change the global implicit wait time using the WithTimeout value.

So this would make the page object and global appium driver implicit wait both change to that value. It would mess the implicit timeout when there are many WithTimeout elements in page objects that contains driver.findElement methods.

There is no getter for implicit wait by design. so it is not easy to fix this.

Solution suggestion:
IMO changing constructors that also passes original timeout duration as argument, in finally block it would set back to original timeout duration.

I created a PR to fix this issue

@truebit Yes. You are right. Thanks for the catching.