I’ve been using Appium with page factory for a while now but never figured out how to properly manage the timeouts and waits with it.
Before page factory, I just used WebDriver wait and set implicit wait to 0 so that there would never be an unneeded wait, but now with Page Factory it seems that I have to rely on Factory’s init method that assigns an implicit timeout (i think?)
Adding more information to that.
PageFactory.initElements(new AppiumFieldDecorator(driver, 10, TimeUnit.SECONDS), this);
Its my first time using PageFactory, so I’m not sure I get this right.
The 10 seconds is the implicit wait time, which is used for:
- every element specified with the annotation such as @FindBy, @AndroidFindBy etc.
- it is NOT used for elements specified using driver.findElement()
Given the above, will
driver.manage().timeouts().implicitlyWait(0);
set the implicit wait to 0 for the driver.findElement() ? Will it also set the implicit wait for annotations or is that always set by PageFactory.InitElements()?
I am looking for a way to set/get implicit wait as I need to reset it to 0 for my scrolling methods - no need to wait if the element isn’t there, I only need to check once and then scroll again until its found.
according to mine experience:
- if i need change timeout for “@FindBy” -> do it with driver.manage()…
- if i need change any timeout for “@AndroidFindBy” or “iOSFindBy” -> just repeat PageFactory.initElements(new AppiumFieldDecorator(driver, need_New_Time, TimeUnit.SECONDS), this);