This project is read-only.

Split button or Context menu on button clcik

Jun 9, 2010 at 7:23 AM

We are in process of evaluating white to use for functional test, we stuck at split button, on click of this split button it popup a drop down list (menu) which is layered using Contexmenu toolkit:menuitem, to search this drop down there is no standard control in white (as mentioned in earlier discussion), I agree to it but I am try to access it as UIItem or Search on a window as AutomationElement but white is unable to locate it.


When we use UIspy to check the component we notice it shows the detail of split button (Button + Text box + Button) but not the menu item.


            When we use UIAVerify it show split button as a single button, we noticed white also acts as shown in UIAVerfy because white also does not recognize the split button as a three different components so to show drop down we have to click on right side of that button (as clcik was pointing to center and which was pointing to diffrent action). This is not the case with Web-Aii, it recognizes those as three components.


            The drop down layered or menu which is displayed on clcik of split down arrow button is not tracked by UIAVerify or UISpy

 Could any one assist us how to deal with this situation in white, i am attaching xmal files with this discussion.

Code in Xaml first:

<my:SplitButton Content="Split Button" x:Name="button1" Click="SplitOption1_Click" HorizontalAlignment="Stretch" Margin="144,38,233,0" VerticalAlignment="Top" d:LayoutOverrides="Width" DataContext="{Binding}">
                   <toolkit:MenuItem x:Name ="option1" Header="Option1" Click="SplitOption1_Click" DataContext="{Binding}" />
                  <toolkit:MenuItem Header="Option2" Click="SplitOption1_Click"/>
                 <toolkit:MenuItem Header="Option3" Click="SplitOption1_Click"/>

Code in Xaml of custom control: (Only part of code)

<Grid x:Name="SplitElement" Grid.Column="2" Background="Transparent">
             <toolkit:ContextMenu ItemsSource="{Binding ButtonMenuItemsSource, RelativeSource={RelativeSource TemplatedParent}}" Foreground="{TemplateBinding Foreground}" FlowDirection="{TemplateBinding FlowDirection}"/>
       <c:DropDownArrow x:Name="BtnArrow"/>



Jun 9, 2010 at 11:34 AM

My problem is solved by using below line code before launching browser window (opening sliverlight through internet explorer) :-

White.Core.Configuration.CoreAppXmlConfiguration.Instance.RawElementBasedSearch = true;
White.Core.Configuration.CoreAppXmlConfiguration.Instance.MaxElementSearchDepth = 50;

In test method after button click to display dorp down i searched forUI item :-

UIItemCollection uitcol = browserWindow.Items;
 foreach (UIItem itm in uitcol)
     Console.WriteLine("AutomationId: " + itm.Id);
     Console.WriteLine("name: " + itm.Name);
     Console.WriteLine("Labe By: " + itm.AutomationElement.Current.LabeledBy);
     Console.WriteLine("Class Name: " + itm.AutomationElement.Current.ClassName);
     Console.WriteLine("to String: " + itm.ToString());

 Result for it was:-





name: Option3

Labe By:

Class Name: TextBlock

to String: WPFLabel. AutomationId:, Name:Option3, ControlType:text, FrameworkId:Silverlight




Then based on info, I retained the Raw based search configuration and searched it:-

 WPFLabel opt3 = browserWindow.Get<WPFLabel>(SearchCriteria.ByText("Option3"));