Click here to Skip to main content
14,390,412 members
Rate this:
Please Sign up or sign in to vote.
Trying to automate the IE's window which appears when any file gets downloaded,
need to click on "Open with" option which is a part of SplitButton,

<img src=''/>

Unable to find the "Open with" option as Child/Descendant of the window, Although rest of the buttons could easily be found.

What I have tried:

Tried recursively find the window, but NO SUCCESS

 AutomationElement elementNode = TreeWalker.ControlViewWalker.GetFirstChild(targetTreeViewElement);

        while (elementNode != null)
            // Test for the control patterns of interest for this sample.
            object objPattern;
            ExpandCollapsePattern expcolPattern;
            if (true == elementNode.TryGetCurrentPattern(ExpandCollapsePattern.Pattern, out objPattern))
                expcolPattern = objPattern as ExpandCollapsePattern;
                if (expcolPattern.Current.ExpandCollapseState != ExpandCollapseState.LeafNode)
                    ExpandCollapsePattern expandPattern = ((ExpandCollapsePattern)expcolPattern);
                    if (expandPattern.Current.ExpandCollapseState != ExpandCollapseState.Expanded)
            TogglePattern togPattern;
            if (true == elementNode.TryGetCurrentPattern(TogglePattern.Pattern, out objPattern))
                togPattern = objPattern as TogglePattern;
                TogglePattern expandPattern = ((TogglePattern)togPattern);
                if (expandPattern.Current.ToggleState != ToggleState.On)
            InvokePattern invPattern;
            if (true == elementNode.TryGetCurrentPattern(InvokePattern.Pattern, out objPattern))
                if (elementNode.Current.Name == "Open with")
                    invPattern = objPattern as InvokePattern;
                    InvokePattern expandPattern = ((InvokePattern)invPattern);

            // Iterate to next element.
            // elementNode - Current element.
            // treeviewIndex - Index of parent TreeView.
            elementNode = TreeWalker.ControlViewWalker.GetNextSibling(elementNode);
Updated 7-Nov-19 0:33am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You can't - you have no control over what the client browser does with the download: understandably, this is a security thing to prevent unwanted downloads being capable of automatically executing and installing malware.
isaketranjan 7-Nov-19 5:40am
But there are tools e.g. Softomotive's ProcessRobot, uipath which does the exact same thing,
So, CANNOT -- i guess, is not the answer. Did you the see the image link which i have attached ?
And Only split button's menu item is not getting retrieved otherwise i can find Open button, Open folder, View Downloads buttons.
And big thanks for your speedy response, Please help me out for this as i am stuck on it for days now
Dave Kreskowiak 7-Nov-19 8:22am
Again, you can NOT pick the app for the client.

All you can do is provide a correct MIME type for the download in the server-side code. The MIME type tells the browser what to do with the content it just downloaded. If the client-side has a handler installed with registered MIME types it can handle, the browser can tell the system to launch the handler with the path to the content it downloaded.

isaketranjan 7-Nov-19 9:07am
Providing MIME type is not an option for me,my project on which i am working on is an AUTOMATION TOOL, and user can select any Window(App), Button, Split button, also, using SENDKEY is not an option for me, i am using Microsoft's uiautomationclient.dll for same.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100