AI AGENT · NEW
Add a custom component
When a BELLATRIX component does not fit a control, your agent adds a custom one in your project. The framework itself stays unchanged.
When you need one
Most controls map to a built-in BELLATRIX component such as Button or ComboBox. Some controls behave differently. For example, the items of a WinUI dropdown appear at the root of the window, not under the dropdown. A custom component wraps that behaviour once, so every test can use it.
The agent often finds such a gap itself while it runs a test case. You can also ask for a component directly.
What to say to your agent
- The unit dropdowns are WinUI ComboBoxes. Add a custom BELLATRIX component for them and use it in UnitConverterWindow.
- Create a custom component for this date picker.
- Why did you add WinUiComboBox?
What you will see
- The agent explains the gap: what the built-in component does and why it fails here.
- It adds a class that inherits from the closest BELLATRIX component and overrides only what differs.
- It switches the page object's map to the new component.
- It builds the project.
Where the files end up
The component goes to Components/ in your test project. The page object's map uses it like any other component:
public class WinUiComboBox : ComboBox
{
public override void SelectByText(string value)
{
// Click the ComboBox to expand the dropdown flyout
WrappedElement.Click();
// Find the list item from the root of the window (WinUI3 popup items may
// appear at the root level of the accessibility tree, not as element children)
new App().Components.CreateByXPath<Button>($"//ListItem[@Name='{value}']").Click();
}
} public WinUiComboBox InputUnitComboBox =>
App.Components.CreateByAutomationId<WinUiComboBox>("Units1"); Under the hood
- The components skill shows the agent how to inherit from a BELLATRIX component and create child elements through the component factories, never through raw driver calls.
- The gap shows up while the agent runs the steps live through the CLI, before it writes any code.
- More: How the agent works.