Skip to main content

Choose a testing helper

The testing helpers are included in ProTest.Avalonia.Headless, and therefore in both xUnit adapter installations. Use them inside an Avalonia test or a manual headless session.

GoalAPIReference
Exercise platform keyboard/mouse processingHeadlessWindowExtensionsPlatform input
Raise pointer events on a selected controlTouchInputSimulator, MouseInputSimulatorTouch, mouse
Compose keyboard shortcuts and text inputKeyboardInputSimulatorKeyboard
Raise processed gesture eventsGestureSimulatorGestures
Feed pointer events through actual recognizersGestureRecognizerTestHelper, MultiTouchTestHelperFactoryRecognizers, multi-touch
Find descendants and inspect ancestryVisualTreeTestHelper, LogicalTreeTestHelperVisual, logical
Combine type, state, name, and property filtersControlFinderControl finder
Query with path expressionsTreeXPathXPath
Validate or compare a treeTreeValidator, TreeComparer, TemplateComparerValidation, comparison, templates
Use Appium-style locators and action chainsAvaloniaDriver, By, Actions, TouchActionAutomation
Wait for changing UI stateDriverWait, ExpectedConditions, WaitHelperWaits
Capture a sequence of framesHeadlessScreenRecorder, RecordedTouchSimulatorRecording
Convert recorded PNGs into a videoVideoConverterVideo conversion

Namespaces​

using Avalonia.HeadlessTestingFramework;
using Avalonia.HeadlessTestingFramework.Appium;
using Avalonia.HeadlessTestingFramework.Recording;

The helpers operate in process. They do not launch a native window or connect to a WebDriver server. Pointer-event helpers target the supplied control; the platform's Window.MouseDown / MouseUp methods exercise hit testing from window coordinates.

Query a control tree​

var panel = new StackPanel
{
Children =
{
new Button { Name = "Save", Content = "Save" },
new TextBox { Name = "Title", Text = "Draft" }
}
};
var window = new Window { Content = panel };
window.Show();
try
{
var save = window.GetByName<Button>("Save");
Assert.True(ControlFinder.From(window).OfType<TextBox>().Any());
Assert.Equal("Save", save.Content);
}
finally
{
window.Close();
}

For recognizer-based gestures, configure handlers and recognizers before attaching the control to a window. See gesture registration.

The API catalog lists every imported source component and its public signatures.