Automate a WPF application
Automate a WPF application
Introduction
When you capture control inside Tab Control, Leapwork captures the entire window/entire tab/parent.
Resolution
In few cases, when you capture control inside Tab Control, Leapwork captures the parent control instead of child control. This happens when control template is not defined as per guidelines for WPF control.
To define the control template, you should ensure that your template matches the defined standard template. The template should have the TabControl class that defines a template part called PART_SelectedContentHost, of type ContentPresenter.
Template
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="EmptyTabControlStyle" TargetType="{x:Type TabControl}">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<ContentPresenter Name="PART\_SelectedContentHost" ContentSource="SelectedContent"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Note: Name="PART_SelectedContentHost" is mandatory for the template to identify the control.
For more information, see TabControl Styles and Templates.
For any clarification, contact our Priority Support.