How to test WPF Popup Control

Jul 10, 2008 at 6:57 AM
Let's say I have a code as below ~

<?xml version="1.0" encoding="utf-8"?>
<Window
    x:Class="WPFApp1.Window1" xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Sample WPF Application for UI Automation Testing"
    Width="565"
    Height="371">
    <Grid>
        <Panel.Children>
            <Popup Name="myPop" PopupAnimation="Slide"
                   StaysOpen="True"  Placement="Center" Width="390" Height="300"
                  >
                <StackPanel>
                    <Label Content="ddddd" />
                    <TextBox Margin="117,37,0,0" Name="myTextbox" Width="170" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top" VerticalContentAlignment="Center" />
                </StackPanel>               
            </Popup>
   

            <Label
                Content="Name" HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Margin="15,19,0,0"
                Width="46"
                Height="24"
                Name="nameLabel"
                Grid.ColumnSpan="2" />
            <TextBox
                Name="nameTextbox"
                Grid.Column="1"
                Grid.Row="0"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Top"
                Margin="20,21,24,0"
                Height="22" />
            <Label
                Content="Label"
                Name="addressLabel"
                Grid.Column="0"
                Grid.Row="0"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Top"
                Margin="15,45,0,0"
                Height="23" />
            <TextBox
                Grid.Column="1"
                Grid.Row="0"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Top"
                Margin="20,46,23,0"
                Height="33"
                Name="addressTextBox" />
            <Button
                Grid.Column="1" VerticalAlignment="Bottom"
                Margin="88,0,75,16"
                Height="31"
                Name="saveButton"
                Content="Save"
                Click="saveButtonClick" />
            <Button
                Grid.Column="1" HorizontalAlignment="Right"
                VerticalAlignment="Bottom"
                Margin="0,0,23,16"
                Width="52"
                Height="31"
                Name="cancelButton"
                Content="Cancel"
                Click="cancelButtonClick" />
            <RadioButton Name="maleRadioButton" Grid.Column="1" Height="21" HorizontalAlignment="Left" Margin="20,84,0,0"  VerticalAlignment="Top" Width="68">Male</RadioButton>
            <RadioButton Height="21" Margin="68.883,84,75,0" Name="femaleRadioButton" VerticalAlignment="Top" Grid.Column="1">Female</RadioButton>
            <TextBox Margin="21,106,23,0" Name="phoneTextbox" Grid.Column="1" Height="22" VerticalAlignment="Top" />
            <TextBox Height="22" Margin="21,0,23,98" Name="websiteTextbox" VerticalAlignment="Bottom" Grid.Column="1" />
            <Label Margin="15,104,0,126" Name="phoneLabel">Phone</Label>
            <Label Height="23" Margin="15,0,0,97" Name="websiteLabel" VerticalAlignment="Bottom">Website</Label>
        </Panel.Children>
        <Grid.ColumnDefinitions>
            <ColumnDefinition
                Width="0.203448275862069*" />
            <ColumnDefinition
                Width="0.796551724137931*" />
        </Grid.ColumnDefinitions>       
    </Grid>
   
</Window>

When I checked it in UIspy, I found that there is no automationid or name or etc. I tried to get the object by using ModalWindow but it doesn't work. Any idea?
Coordinator
Jul 11, 2008 at 5:49 AM
Have you tried window.PopupMenu method.