Skip to content

Conversation

@TikhomirovSergey
Copy link
Contributor

Change list:

  • The new annotation WithTimeout has been added. It provides the ability to define element rendering timeout when it differs from general values. For example some elements appear slower or some elements are used just for checkings/assertions.

Use case:

@AndroidFindBy("locator") MobileElemente1; //test will wait for this element during default time@WithTimeout(timeOut = 20, timeUnit = TimeUnit.SECONDS) @AndroidFindBy("locator2") MobileElemente2; //test will wait for this diring 20 seconds
  • AppiumFieldDecorator has been bit redesigned. Now it only decorates WebElement/MobileElement fields.

Use case:

PageFactory.initElements(newAppiumFieldDecorator(driver), pageObject//an instance of PageObject.class ); //or PageFactory.initElements(newAppiumFieldDecorator(driver, 15, //default implicit waiting timeout for all strategiesTimeUnit.SECONDS), pageObject//an instance of PageObject.class );

If it is extramally needed to change default time for the waiting of elements the following is possible:

timeOutDuration = newTimeOutDuration(10, TimeUnit.SECONDS); PageFactory.initElements(newAppiumFieldDecorator(driver, timeOutDuration), pageObject); //user code//here timeout has to be changedtimeOutDuration.setTime(15, TimeUnit.SECONDS); 

@TikhomirovSergey
Copy link
ContributorAuthor

After the coversation with @Simon-Kaz I'm going to improve the new annotation

@WithTimeout(time = 20, unit = TimeUnit.SECONDS)

@Jonahss
Copy link
Member

oh I like this. Definitely makes it easier to define tests. Will merge when @TikhomirovSergey and @Simon-Kaz gives thumbs-up

@TikhomirovSergey
Copy link
ContributorAuthor

I've finished
👍 :)

@Simon-Kaz
Copy link

👍 Going to use this a lot :)

@Jonahss
Copy link
Member

super.

Jonahss added a commit that referenced this pull request Jun 29, 2015
@JonahssJonahss merged commit ddac8ff into appium:masterJun 29, 2015
@truebit
Copy link
Contributor

truebit commented Apr 26, 2016

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.

publicvoidsetTimeOut(longimplicitlyWaitTimeOut, TimeUnittimeUnit){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?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@TikhomirovSergey@Jonahss@Simon-Kaz@truebit