Scroll in a ScrollView
To simulate a scroll, use the ScrollWheel() method from the PanelSimulator class.
The following example shows how to simulate scrolling inside a ScrollView:
[Test]
public void ScrollExample()
{
// Make sure the UI is totally up to date.
simulate.FrameUpdate();
// Fetch the scrollView.
var scrollView = rootVisualElement.Q<ScrollView>("MyScrollView");
var scrollViewStateBefore = scrollView.scrollOffset;
// Send events to scroll the mouse wheel.
simulate.ScrollWheel(new Vector2(0, 0.5f),
rootVisualElement.worldBound.center);
simulate.FrameUpdate();
Assert.That(scrollView.scrollOffset, Is.Not.EqualTo(scrollViewStateBefore));
}