2015-07-03 21 views
2

Inspect.exe显示IsSelectionPatternAvailabletrue,但是当调试在VS2013 SelectionItemPattern,只是引发错误:IsSelectionPatternAvailable是真实的,但GetCurrentPattern(SelectionItemPattern.Pattern)中断

An unhandled exception of type 'System.InvalidOperationException' occurred in UIAutomationClient.dll, Additional information: Unsupported Pattern.

IE 11.0 + Win7的64位,谁能帮我?

Dim cond1 = New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Tab) 
    Dim cond2 = New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem) 
    Dim tab = AutomationElement.FromHandle(browserHandle).FindFirst(TreeScope.Descendants, cond1) 
    Dim tabs = tab.FindAll(TreeScope.Children, cond2) 
    For i = 0 To tabs.Count - 1 
     Dim tabA = tabs(i) 
     Dim a As SelectionItemPattern = tabA.GetCurrentPattern(SelectionItemPattern.Pattern) 
    Next 

回答

1

我遇到了问题,因为我遇到了同样的问题。使用UIAVerify SelectionItemPattern是可用的,但使用代码是不可能的。

原来,UIAVerify使用了UIComWrapper.dll,它也公开了System.Windows.Automation.AutomationElement(和其他东西)。所以我用UIAComWrapper替换了References部分中的UIAutomationTypes和UIAutomationClient,并且突然发现代码起作用了!

我知道我正在测试的应用程序部分是旧的和新的技术。新的部分与UIAutomation一起工作....但是旧部分是问题发生的地方,所以使用UIAComWrapper对我来说很有意义。

相关问题