【问题标题】:coded ui control polling instead of wait for control exists编码的 ui 控件轮询而不是等待控件存在
【发布时间】:2017-01-18 09:33:01
【问题描述】:

我编写了包含大量WaitForControlExists 的ui 测试。这会导致我的测试运行缓慢。

基本上,如果Playback.PlaybackSettings.SearchTimeout = 30000; 和我有uicontrol.WaitForControlExists(),则需要 30 秒才能从方法中获得反馈,即使控件在 1 秒后显示。

现在我想知道是否有办法在控件存在后立即退出WaitForControlExist?说,我“轮询控制存在”而不是“等待控制存在”。

我会将轮询计时器设置为 1 秒。这意味着我每秒检查一次控件是否存在。如果它在 2 秒(或任何小于 30 秒)后显示,则返回 true 并停止轮询,如果在 30 秒后没有继续尝试每秒,则退出并返回 false。

【问题讨论】:

    标签: c# automated-tests coded-ui-tests


    【解决方案1】:

    你可以这样设置:

    var exists = uiControl.WaitForControlExists(100);
    var counter = 0;
    while(!exists)
    {
       Playback.Wait(1000);
       counter++;
       exists = uiControl.WaitForControlExists(100);
       if(counter>30)
           break;
    }
    

    您也可以尝试使用 WaitForControlReady

    【讨论】:

      【解决方案2】:

      使用 uiControl.WaitForControlCondition(control => control.Condition,timeout);

      这样,您可以在继续执行之前混合和匹配您希望满足的控制条件。

      对我来说最有用的是控件的状态和样式。 玩得开心:)

      【讨论】:

        猜你喜欢
        • 2013-08-11
        • 2016-02-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多