Invoking and using modal dialog

Apr 24, 2008 at 3:55 PM
I have a button inside a tool strip that invokes a modal dialog. The White invoke call (see below) places the cursor at the clickable point, but the dialog does not appear. The Automation invoke call (commented out, below the White invoke call) blocks, so I cannot manipulate anyting in the modal dialog.

I have tried this running my test program under .Net Framework 3.0 and 3.5. The application being tested runs under 3.0.

Any advice?

Condition addButtonCondition = new PropertyCondition(AutomationElement.NameProperty, "toolStripButton1");
AutomationElement addButtonAE = toolStrip1AE.FindFirst(TreeScope.Subtree, addButtonCondition);
ProcessActionListener pal = new ProcessActionListener(addButtonAE);
Button b = new Button(addButtonAE, pal);
b.Click();
// InvokePattern addButtonPattern = (InvokePattern)addButtonAE.GetCurrentPattern(InvokePattern.Pattern);
// addButtonPattern.Invoke();
Apr 24, 2008 at 4:11 PM
Since posting the question, I have found a workaround. I replaced b.Click() with:

b.Focus();
b.Click();
Thread.Sleep(2000);
b.Click();

(using April 23 release of White)
Coordinator
Apr 24, 2008 at 5:41 PM
When you do this manually, do you have to click twice? Once to get focus and once to click on the button?

Also aren't you able to find the button from the toolbar by calling toolBar.Get<Button>("toolStripButton1"). You shouldn't have to use AutomationElement at all?
Apr 25, 2008 at 4:29 PM
Edited Apr 25, 2008 at 4:34 PM


viveksingh wrote:
When you do this manually, do you have to click twice? Once to get focus and once to click on the button?


Yes. That's how I noticed that it wasn't a problem with the Invoke method. It may have to do with the button being inside the smart client application block - anyway, it works.


Also aren't you able to find the button from the toolbar by calling toolBar.Get<Button>("toolStripButton1"). You shouldn't have to use AutomationElement at all?


I didn't realize that a ToolBar acts like a Window and has a Get method.

Thanks for your response, and for a good tool. :)