white学习8(官方网站的内容)

Wait handling

White strives to eliminate any need whatsoever for doing Thread.Sleep and retry in your test programs. So if you find yourself doing these things in your program, please use any one applicable options below. If you don't find it, please raise an issue.

1. When any action is performed white automatically waits till the window can respond again to next action. One of the thing white does during this is to call windowPattern.WaitForInputIdle on the parent window of the UI item on which the action is performed. In cases where the window would be closed as a result of the action performed, this call would throw exception internally, depending on timing of the call. The caller doesn't have to worry about this as this exception is trapped.
All of this happens by default, without having to configure anything.
2. Wait based on presence of hour glass. This can be configured by using WaitBasedOnHourGlass property (default value true). This ensures that the test would wait till the cursor remains in hour-glass or default-and-hour-glass. When configured it would happen for each and every action. It is very common in applications to not use hour glass to provide feedback to the user when the application is busy. It is highly recommended to do this, as WaitWhileBusy call on the process object in .NET is not reliable at all.
mouse.JPG
3. There are cases where the above two strategy aren’t enough and hence white provides its own wait mechanism. In this test program waits until the certain condition matches. As soon as the condition matches it would return. There is maximum wait duration. This duration can be configured by setting BusyTimeout property.

There are other places where you need to set the timeout (all in milli seconds set to some defaults).
Property Description
PopupTimeout Timeout period for finding a popup
TooltipWaitTime Maximum duration in within which tooltip would appear (see Tool tip problem)
SuggestionListTimeout Timeout period for finding a suggestion list on a textbox
UIAutomationZeroWindowBugTimeout Timeout till any window is found for an application. There is a bug in UIAutomation because of which it sometimes doesn’t find windows for a process

For configuring above have a look at the Configuration section
Timeout means the upper time limit of search. White keeps trying till this time, after every 100 ms.

Custom wait hook

In addition to wait provided by default by white, as mentioned above. From release 0.20 onwards you can also hook in custom wait mechanism. This hook gets called every time after the above wait checks are performed. In this hook you can wait for your conditions to finish. This is useful if your wait scenarios are quite pervasive and you have put in this check at lot of places in your test.
Steps to hook you custom wait:
  1. Implement the interface White.Core.Configuration.IWaitHook.
  2. Implement the WaitFor method in it to wait for as long as your test requires. White passed in the UIItemContainer (most of the time this is just the window) object to provide the context of call. e.g. you can wait till you can find a UI Item in this container.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值