What's a good way to find a button on a panel?

Apr 1, 2010 at 12:52 PM

I got handed a WPF application that I'm attempting to build regression tests for.  I originally started with UIAutomation - but thank god for White.  Much faster, and the code is simpler.

Here's the situation:  I have a button with an AutmationID sitting on a Pane (with an AutomationID), sitting on a TabItem that IsSelected.  What's the best way to access the button to be able to select it?  I am able to get the TabItem, but I can't figure out how to retrieve the button from the pane.

Thanks

Phil

Apr 1, 2010 at 1:40 PM

Use UISpy or VisualUIAVerify tool to look at  the structure / hierarchy of your WPF controls. You may need to subclass CustomUIItem to represent your custom control (http://white.codeplex.com/wikipage?title=Custom%20UI%20Item&referringTitle=Home).

BTW, White can't be faster that UIAutomation since it's just an API wrapper around UIAutomation.

 

Apr 1, 2010 at 2:59 PM

I know it's a wrapper - but the response is a heck of a lot faster, than the UIAutomation code that I was writing.

But I was able to figure out - Panel is a UIItemContainer, so once I was able to get to that level, then the Get<> methods were available to me, to help speed up the search.

Apr 1, 2010 at 3:32 PM

Note:

on WPF Get<> is available on each element if you use

using White.Core.UIItems.WPFUIItems;

 

Throndorin

 

Apr 1, 2010 at 6:49 PM

Cool - I'll have to look into that.

Thanks

Mar 14, 2011 at 9:43 PM

Treadhead, I'm wondering if you found a solution that might help me.

I can drill down as far as TabItem, but it appears I can't find any children inside it.  How did you get to your "Panel is a UIItemContainer" revelation, and how did it help you?

I'm concerned that I have the same problem as this guy:

http://white.codeplex.com/discussions/209254?ProjectName=white

in which case I hope I'm not out of luck.

Mar 15, 2011 at 7:41 AM

Hi

maybe Custom Commands can help you, but I haven't used them still now.

They are available since White 2.0

 

Throndorin