Inspect.exe show IsSelectionPatternAvailable is true, but when debug to SelectionItemPattern in VS2013, just raise error:
An unhandled exception of type 'System.InvalidOperationException' occurred in UIAutomationClient.dll, Additional information: Unsupported Pattern.
IE 11.0 + Win7 64bit , Can someone help me?
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
I came across the question, because I got the same problem. Using UIAVerify the SelectionItemPattern was available and usable, but using the code it was not possible.
It turned out, that UIAVerify used the UIComWrapper.dll which exposes also the System.Windows.Automation.AutomationElement (and other stuff). So I replaced the UIAutomationTypes and UIAutomationClient in the References section with the UIAComWrapper and suddendly the code worked!
I know that the application I'm testing was partially old and new technology. The new part was working with the UIAutomation.... But the old part was where the problem occurred, so it makes sense for me using the UIAComWrapper.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With