Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IsSelectionPatternAvailable is true but GetCurrentPattern(SelectionItemPattern.Pattern) interrupt

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
like image 554
brick Avatar asked Aug 18 '26 00:08

brick


1 Answers

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.

like image 158
Helmut Avatar answered Aug 20 '26 12:08

Helmut