TabbedMdiContainer error during Coded UI Tests

Docking/MDI for WPF Forum

Posted 5 years ago by Sasha
Version: 14.1.0601
Avatar

Hi,

We are using Actipro controls in our application and to test UI we are using Coded UI Tests(Visual Studio Ultimate 2013 Update1).

In application we have main window and several additional windows with Actipro controls. This additional windows are windows with TabbedMdiContainers and some element like checkboxs, combobox etc. inside TabbedMdiContainer.

When runnig Coded UI Tests if just to open additional window and close it(without changing states of checkboxes, for example), test passes. If to do the same, but change state of checkbox, we get error : 

Result Message: Test method TestsForAuswertung.CodedUITest1.WithClicks threw exception: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties.

Additional Details: TechnologyName: 'UIA'

FrameworkId: 'Wpf'

ControlType: 'CheckBox'

AutomationId: 'CheckBox_1'

Search may have failed at 'TabbedMdiContainer-a259c6fe-e9e7-477d-a2f5-eab0571...' Pane as it may have virtualized children. If the control being searched is descendant of 'TabbedMdiContainer-a259c6fe-e9e7-477d-a2f5-eab0571...' Pane then including it as the parent container may solve the problem. ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.

Any help is appreciated.

Comments (7)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Sasha,

Container controls in the Docking/MDI product are created/destroyed as needed and each instance will have a unique GUID ID.  Thus the AutomationID will change as they are created.  That being said, I believe you can manually set the AutomationProperties.AutomationID for each container in your test.  That way you can give it a specific ID that won't change between run sessions.


Actipro Software Support

Posted 5 years ago by Sasha
Avatar

I have such xaml code:

 <DockPanel x:Uid="DockPanel_2" Grid.Row="1" AutomationProperties.AutomationId="3fa28ea4-9781-4df7-b567-967900a57d1b">
                <docking:DockSite x:Uid="DockSite_1" CanDocumentWindowsClose="False" AutomationProperties.AutomationId="1c1f4124-6a87-43a0-8f91-1b46de6c48ff">
                    <docking:SplitContainer x:Uid="SplitContainer_1" AutomationProperties.AutomationId="9463fb9a-34dd-48df-9d10-a7bc565e512b">
                        <docking:Workspace x:Uid="Workspace_1" BorderBrush="#898C95" BorderThickness="1" AutomationProperties.AutomationId="cd7e5931-f9a3-483d-b3ee-2c058beaee43">
                            <docking:Workspace.LayoutTransform>
                                <ScaleTransform x:Uid="ScaleTransform_1" ScaleX="{Binding Value, ElementName=scaleSlider}" ScaleY="{Binding Value, ElementName=scaleSlider}" />
                            </docking:Workspace.LayoutTransform>
                            <docking:Workspace.Background>
                                <LinearGradientBrush x:Uid="LinearGradientBrush_1" StartPoint="0,0" EndPoint="1,0">
                                    <GradientStop x:Uid="GradientStop_1" Offset="0.5" Color="#FF80A6C4" />
                                    <GradientStop x:Uid="GradientStop_2" Offset="0.8" Color="#FFC5C5DE" />
                                </LinearGradientBrush>
                            </docking:Workspace.Background>
                            <Grid x:Uid="Grid_2">
                                <Grid.RowDefinitions>
                                    <RowDefinition x:Uid="RowDefinition_4" Height="1" />
                                    <RowDefinition x:Uid="RowDefinition_5" Height="*" />
                                </Grid.RowDefinitions>
                                <docking:TabbedMdiHost x:Uid="TabbedMdiHost_1" Grid.Row="1" IsCloseButtonOnTab="False" AutomationProperties.AutomationId="e24ab41a-c294-48d7-a1bb-02eae3802ada" >
                                    <docking:SplitContainer x:Uid="SplitContainer_2" Orientation="Vertical" AutomationProperties.AutomationId="a1d003f9-04f2-4c6a-9841-823c2c4a3e15">
                                        <docking:SplitContainer x:Uid="SplitContainer_3" Orientation="Horizontal" AutomationProperties.AutomationId="c265336f-f6fe-4243-97e0-b89e2fc0132c">
                                            <docking:TabbedMdiContainer x:Uid="TabbedMdiContainer_1" AutomationProperties.AutomationId="82a75c0f-1da9-4b53-abe8-eb60ae07f6f7">
                                               <docking:DocumentWindow x:Uid="DocumentWindow_1" Title="Title" AutomationProperties.AutomationId="1780ba89-cdf3-4a22-bf68-6f1293d43774" >
                                                <ScrollViewer x:Uid="ScrollViewer_1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" AutomationProperties.AutomationId="4ed7f8ce-c4d3-44ec-9fe6-e367bcbca4ca">
                                                    <views:AnimatedCanvas x:Uid="AnimatedCanvas" AutomationProperties.AutomationId="62cb83b9-2924-4919-a4fb-a1bd82a3458f">
                                                        <ScrollViewer x:Uid="ScrollViewer_2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
															Width="{Binding ActualWidth, ElementName=SecondAnimatedCanvas, UpdateSourceTrigger=PropertyChanged}"
															Height="{Binding ActualHeight, ElementName=SecondAnimatedCanvas, UpdateSourceTrigger=PropertyChanged}" AutomationProperties.AutomationId="ec3b050f-b7ee-4d45-9f62-342c5bc5b827">
                                                            <Grid x:Uid="Grid_3" AutomationProperties.AutomationId="f9843d4d-b172-4582-99f7-fdc66c27fbcd">
                                                                <Grid.ColumnDefinitions>
                                                                    <ColumnDefinition x:Uid="ColumnDefinition_1" Width="Auto"/>
                                                                    <ColumnDefinition x:Uid="ColumnDefinition_2" Width="Auto" />
                                                                    <ColumnDefinition x:Uid="ColumnDefinition_3" Width="*" />
                                                                </Grid.ColumnDefinitions>
                                                                <Grid.RowDefinitions>
                                                                    <RowDefinition x:Uid="RowDefinition_6" Height="Auto"/>
                                                                </Grid.RowDefinitions>

                                                                <TextBlock x:Uid="TextBlock_6" AutomationProperties.AutomationId="ce01afee-ad31-4e2d-a420-5cc2e706de11" Grid.Column="0" Grid.Row="0" Text="CheckBox" />
                                                                <TextBlock x:Uid="TextBlock_7" AutomationProperties.AutomationId="b3b053a9-905e-43a8-8fb9-c9c7ca096e29" Grid.Column="1" Grid.Row="0" Text=":"  />
                                                               <CheckBox x:Uid="CheckBox_1" AutomationProperties.AutomationId="50f91c73-0ef9-44fb-a2a0-23c2d5d92db2" Grid.Column="2" Grid.Row="0" VerticalAlignment="Center" IsChecked="True"  />

                                                            </Grid>
                                                        </ScrollViewer>
                                                    </views:AnimatedCanvas>
                                                </ScrollViewer>
                                            </docking:DocumentWindow>
                                            </docking:TabbedMdiContainer>
                                        </docking:SplitContainer>
                                    </docking:SplitContainer>
                                </docking:TabbedMdiHost>
                            </Grid>
                        </docking:Workspace>
                    </docking:SplitContainer>
                </docking:DockSite>
            </DockPanel>

 When I run coded UI test and try to access checkBox, I get this error. But if I put this checkbox outside container and rebuild test, then it passes...  Any ideas why it is happening?

Thank you. 

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Sascha,

On a side note, you can't put controls like your Grid between the Workspace and the TabbedMdiHost.  That will cause problems in a production app since the Workspace expects MDI containers, if present, to be direct children.

Thank you for the test.  We've been working with it, but haven't been able to get the Coded UI to find the DocumentWindow within the TabbedMdiContainer as of yet.  I'm not sure why it's not finding it since when you look at the automation tree in UIVerify, it does show the DocumentWindow as a child of the TabbedMdiContainer.


Actipro Software Support

Posted 5 years ago by Sasha
Avatar

Hi,

Thank you for pointing on my error.

About this issue with UI test - can you let us know, when you will fix this, because it is very important for our company.

Thank you for your help.

[Modified 5 years ago]

Answer - Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Sasha,

We spent quite a while on this and ended up narrowing down the sample XAML you posted above.  It started working after I removed the nested ScrollViewer.  Basically it seemed like if there was a ScrollViewer in another ScrollViewer, it stopped finding controls.  Please try that out and see if it helps on your end.  If not, I'll send you the XAML we used to test.


Actipro Software Support

Posted 5 years ago by Sasha
Avatar

Hi,

Yes, now it is working.

I just would like to know, if it is a bug, or we need to remove nested scrollViewer?

Thank you for your help.

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

It seems to be a bug in Coded UI so I would suggest coming up with a different usage scenario than nested ScrollViewers.


Actipro Software Support

The latest build of this product (v2018.1 build 0675) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.