This project is read-only.

ElementNotFoundException after I successfully click button to close window

Apr 3, 2012 at 1:53 PM

Hi all,

I am getting an ElementNotFoundException while trying to click a (cancel) button. The button simply closes the window.

The close action however is successful.

Something inside click() method still wants to find the button even after it got clicked.

Thoughts please.

Thanks in advance.


Apr 3, 2012 at 1:59 PM


you can try to use the Invoke Pattern from UIAutomation on the button.AutomationElement.

If this shows the same error, I would catch these special exception at these special point, write some information as Trace and continue the test.



Apr 3, 2012 at 2:30 PM

Thanks, I am now doing something similar. Will give Invoke Pattern a try though.

                    var ok3 = GeneralWhiteUtils.FindButton("1", 3, app);
                catch (ElementNotAvailableException)

Apr 6, 2012 at 8:28 AM

Invoke Pattern  does work , my bad ^_^

Apr 6, 2012 at 9:56 AM

something like this in a static class-


         public static void ClickUsingInvokePattern(this White.Core.UIItems.Button whiteButton)
            var ae = whiteButton.AutomationElement;
            InvokePattern ip = (InvokePattern)ae.GetCurrentPattern(InvokePattern.Pattern);