We have a WPF Application that when I use a coded step rather than a Test Step, I get an error message that the Element cannot be found. If the coded step is after a Test Step that does interact with the same page, the Element is found with no issues.
Here is the Element example:
XamlTag=button,AutomationId=Vendor Search
If I set a breakpoint and open the DOM Explorer, and then close it, the Element is found as expected. Just stopping at the breakpoint is not enough, so it isn't an issue with waiting for the Element to be populated.
This issue also happens when we export our test to be a C# coded test.
I have attached a video showing the behavior working and then breaking. We are unable to share the program with you since it is an internal application.
Coded Step:
[CodedStep(@"Click VendorSearchButton")]
public void Purchasing_CodedStep8()
{
System.Threading.Thread.Sleep(1000);
Applications.IdsLocalRunnerexe.Purchasing__Webstaurant_Store_Inc__Inventory_Distribution_System.VendorSearchButton.Wait.ForExists();
// Click VendorSearchButton
Applications.IdsLocalRunnerexe.Purchasing__Webstaurant_Store_Inc__Inventory_Distribution_System.VendorSearchButton.User.Click();
}
Here is the code within the application setting the AutomationId:
<Button x:Name="NavigateButton" Margin="0,1,0,0" Command="{Binding CommandOnClick}" IsEnabled="{Binding Enabled}"
Height="43" VerticalAlignment="Center" HorizontalAlignment="Stretch"
Style="{StaticResource MenuItemButtonStyle}"
AutomationProperties.Name="{Binding DisplayText}"
AutomationProperties.AutomationId="{Binding DisplayText}"
Visibility="{Binding IsEditable, Converter={StaticResource BooleanInverseVisibilityConverter}}">
<TextBlock Foreground="{StaticResource MenuItemTextBrush}" FontSize="14" Padding="4"
Visibility="{Binding IsEditable, Converter={StaticResource BooleanInverseVisibilityConverter}}">
<Run Text="{Binding Index, Mode=OneWay}" FontWeight="Thin" /><Run Text="." FontWeight="Thin" />
<Run Text="{Binding DisplayText, Mode=OneWay}" FontWeight="SemiBold" />
</TextBlock>
</Button>