首页 > 解决方案 > 使用 FlaUI 自动化在 WPF 应用程序中获取进度条的可见性

问题描述

我正在使用FlaUI自动化WPF应用程序。我有一个Inderminate进度。一旦进度条得到CollapsedUI就会被加载。我想在 ProgressBar 上实现一种机制,但我无法通过RetryVisibilitypropertyFlaUI

private ProgressBar LoadingStatus => _uiAutomation.FindElement("ShowProgress", Automation.FindBy.Id).AsProgressBar();

<ProgressBar AutomationProperties.AutomationId="ShowProgress"
                Grid.Row="1"
                Height="4"
                Margin="0"
                BorderThickness="0"
                IsIndeterminate="True"
                IsTabStop="False"
                ToolTip="Contacting Server, Please Wait..."
                Visibility="{Binding IsServerActive, Converter={StaticResource MwBoolToVisibilityConverterReverse}}" />

我想实现 aRetry.While((LoadingStaus_Is_Collapsed)=> )};但似乎我无权访问该visibility属性。我怎样才能完成它?

标签: c#wpf-controlsmicrosoft-ui-automationflaui

解决方案


在这里工作的属性是IsOffScreen。UIA 框架提供此属性,因为 Visibility 是一个WPF属性,而不是UIA. IsOffScreen如果元素当前不在屏幕上,则返回 True 否则返回False。这就是我使用它的方式

public bool LoadingStatusVisibiltity()
        {
            _logger.Info("Retrieving data from the server.Please wait!");
            if (LoadingStatus.IsOffscreen)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

推荐阅读