如何在手写 UI 测试中单击下拉菜单中列出的选项之一?

How to click one of the options listed in the drop down menu in hand coded UI testing?

        UITestControl uiLinkAboutus = new UITestControl(_bw);
        uiLinkAboutus.TechnologyName = "Web";
        uiLinkAboutus.SearchProperties.Add("ControlType", "Image");
        uiLinkAboutus.SearchProperties.Add("TagName", "IMG");
        uiLinkAboutus.SearchProperties.Add("Alt", "Open Menu");
        Mouse.Click(uiLinkAboutus);

/* 执行时,点击了下拉按钮,但没有点击下面列出的选项。如何解决这个问题呢?

不搜索图像,而是使用 wpfCombobox、winCombobox 或 HtmlComboBox 控件搜索列表或下拉控件。在那里您将 selectedItem 属性 设置为您想要的值。这是在 UI 中选择项目的最可靠方法。所以例如: ApplicationUnderTest aut = ApplicationUnderTest.Launch(@"yourapp.exe");   WpfComboBox cbBox = new WpfComboBox(aut); cbBox.SearchProperties.Add(WpfComboBox.PropertyNames.AutomationId,"cmbCountries");//AutomationId == xName roperty cbBox.SelectedItem = "your value";