Fix #203 by TikhomirovSergey · Pull Request #210 · appium/java-client

I used timeOutDuration.setTime(10, TimeUnit.SECONDS); to change global timeout in a driver wrapper class, but according to the debug log, the element find timeout is always 0:

What I did in the driver wrapper class is like below. timeOutDuration is a field in wrapper class. PageObject would create constructor with the wrapper class, so PageObject could use it.

   public void setTimeOut(long implicitlyWaitTimeOut, TimeUnit timeUnit) {
        timeOutDuration.setTime(implicitlyWaitTimeOut, timeUnit);
        getDriver().manage().timeouts().implicitlyWait(timeOutDuration.getTime(), timeOutDuration.getTimeUnit());
        getDriver().manage().timeouts().pageLoadTimeout(timeOutDuration.getTime(), timeOutDuration.getTimeUnit());
    }

here below is the log when trying to finding an element for accessibility named "我的". In the log, there are two timeouts requested. one is using 0, and the other is 10 seconds(what I set)

[HTTP] --> POST /wd/hub/session/ad1b6bb5-d17f-4ee3-be3d-3829cd4b6a2c/timeouts {"type":"implicit","ms":0}
[MJSONWP] Calling AppiumDriver.timeouts() with args: ["implicit",0,"ad1b6bb5-d17f-4ee3-be3d-3829cd4b6a2c"]
[debug] [iOS] Executing iOS command 'timeouts'
[MJSONWP] Responding to client with driver.timeouts() result: null
[HTTP] <-- POST /wd/hub/session/ad1b6bb5-d17f-4ee3-be3d-3829cd4b6a2c/timeouts 200 2 ms - 76
[HTTP] --> GET /wd/hub/session/ad1b6bb5-d17f-4ee3-be3d-3829cd4b6a2c/context {}
[MJSONWP] Calling AppiumDriver.getCurrentContext() with args: ["ad1b6bb5-d17f-4ee3-be3d-3829cd4b6a2c"]
[debug] [iOS] Executing iOS command 'getCurrentContext'
[MJSONWP] Responding to client with driver.getCurrentContext() result: "NATIVE_APP"
[HTTP] <-- GET /wd/hub/session/ad1b6bb5-d17f-4ee3-be3d-3829cd4b6a2c/context 200 3 ms - 84
[HTTP] --> POST /wd/hub/session/ad1b6bb5-d17f-4ee3-be3d-3829cd4b6a2c/elements {"using":"accessibility id","value":"我的"}
[MJSONWP] Calling AppiumDriver.findElements() with args: ["accessibility id","我的","ad1b6bb5-d17f-4ee3-be3d-3829cd4b6a2c"]
[debug] [iOS] Executing iOS command 'findElements'
[debug] [BaseDriver] Waiting up to 0 ms for condition
[debug] [UIAuto] Sending command to instruments: au.getElementsByAccessibilityId('我的')
[debug] [Instruments] [INST] 2016-04-26 10:47:26 +0000 Debug: Got new command 5 from instruments: au.getElementsByAccessibilityId('我的')
[debug] [Instruments] [INST] 2016-04-26 10:47:26 +0000 Debug: evaluating au.getElementsByAccessibilityId('我的')
[debug] [Instruments] [INST] 2016-04-26 10:47:27 +0000 Debug: evaluation finished
[debug] [Instruments] [INST] 2016-04-26 10:47:27 +0000 Debug: Lookup returned [object UIAButton] with the name "我的" (id: 1).
[debug] [Instruments] [INST] 2016-04-26 10:47:27 +0000 Debug: responding with:
[debug] [Instruments] [INST] 2016-04-26 10:47:27 +0000 Debug: Running system command #6: /usr/local/Cellar/node/5.9.1/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-ios-driver/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js /var/folders/tf/ltnjwy0j0sn_1m58yhbm1j0h0000gn/T/instruments_sock 2,{"status":0,"value":[{"ELEMENT":"1"}]}...
[debug] [UIAuto] Socket data received (40 bytes)
[debug] [UIAuto] Got result from instruments: {"status":0,"value":[{"ELEMENT":"1"}]}
[MJSONWP] Responding to client with driver.findElements() result: [{"ELEMENT":"1"}]
[HTTP] <-- POST /wd/hub/session/ad1b6bb5-d17f-4ee3-be3d-3829cd4b6a2c/elements 200 1741 ms - 89
[HTTP] --> POST /wd/hub/session/ad1b6bb5-d17f-4ee3-be3d-3829cd4b6a2c/timeouts {"type":"implicit","ms":10000}
[MJSONWP] Calling AppiumDriver.timeouts() with args: ["implicit",10000,"ad1b6bb5-d17f-4ee3-be3d-3829cd4b6a2c"]
[debug] [iOS] Executing iOS command 'timeouts'
[MJSONWP] Responding to client with driver.timeouts() result: null
[HTTP] <-- POST /wd/hub/session/ad1b6bb5-d17f-4ee3-be3d-3829cd4b6a2c/timeouts 200 2 ms - 76
2016-四月-26 18:47:27,608 [AppiumCabbie.java 58] INFO - press on element : [[IOSDriver: on MAC (ad1b6bb5-d17f-4ee3-be3d-3829cd4b6a2c)] -> accessibility id: 我的] [main]

Could you tell me why timeout 0 is requested instead of my custom set (10)? and what is the correct way doing global wait timeout for all PageObjects?