Move the mouse to a visual element
To move the mouse to a specified position, use the MouseMove() method from the PanelSimulator class.
The following example shows how to move the mouse to a visual element, such as a button:
[Test]
public void MouseMoveExample()
{
// Make sure the UI is totally up to date.
simulate.FrameUpdate();
// Fetch the button
var button = rootVisualElement.Q<Button>("MyButton");
Assume.That(button.hasHoverPseudoState, Is.False);
// Send events to mouse over the button.
simulate.MouseMove(button.worldBound.center);
simulate.FrameUpdate();
Assert.That(button.hasHoverPseudoState, Is.True);
}