diff --git a/tests/Avalonia.IntegrationTests.Appium/MenuTests.cs b/tests/Avalonia.IntegrationTests.Appium/MenuTests.cs index d1d231466f..3f1fe7de12 100644 --- a/tests/Avalonia.IntegrationTests.Appium/MenuTests.cs +++ b/tests/Avalonia.IntegrationTests.Appium/MenuTests.cs @@ -60,6 +60,8 @@ namespace Avalonia.IntegrationTests.Appium [PlatformFact(TestPlatforms.Windows)] public void Select_Child_With_Alt_Arrow_Keys() { + MovePointerOutOfTheWay(); + new Actions(_session) .KeyDown(Keys.Alt).KeyUp(Keys.Alt) .SendKeys(Keys.Down + Keys.Enter) @@ -72,6 +74,8 @@ namespace Avalonia.IntegrationTests.Appium [PlatformFact(TestPlatforms.Windows)] public void Select_Grandchild_With_Alt_Arrow_Keys() { + MovePointerOutOfTheWay(); + new Actions(_session) .KeyDown(Keys.Alt).KeyUp(Keys.Alt) .SendKeys(Keys.Down + Keys.Down + Keys.Right + Keys.Enter) @@ -84,6 +88,8 @@ namespace Avalonia.IntegrationTests.Appium [PlatformFact(TestPlatforms.Windows)] public void Select_Child_With_Alt_Access_Keys() { + MovePointerOutOfTheWay(); + new Actions(_session) .KeyDown(Keys.Alt).KeyUp(Keys.Alt) .SendKeys("rc") @@ -96,6 +102,8 @@ namespace Avalonia.IntegrationTests.Appium [PlatformFact(TestPlatforms.Windows)] public void Select_Grandchild_With_Alt_Access_Keys() { + MovePointerOutOfTheWay(); + new Actions(_session) .KeyDown(Keys.Alt).KeyUp(Keys.Alt) .SendKeys("rhg") @@ -111,6 +119,8 @@ namespace Avalonia.IntegrationTests.Appium var rootMenuItem = _session.FindElementByAccessibilityId("RootMenuItem"); rootMenuItem.SendClick(); + MovePointerOutOfTheWay(); + new Actions(_session) .SendKeys(Keys.Down + Keys.Enter) .Perform(); @@ -125,6 +135,8 @@ namespace Avalonia.IntegrationTests.Appium var rootMenuItem = _session.FindElementByAccessibilityId("RootMenuItem"); rootMenuItem.SendClick(); + MovePointerOutOfTheWay(); + new Actions(_session) .SendKeys(Keys.Down + Keys.Down + Keys.Right + Keys.Enter) .Perform(); @@ -159,5 +171,15 @@ namespace Avalonia.IntegrationTests.Appium Assert.True(textBox.GetIsFocused()); } + + private void MovePointerOutOfTheWay() + { + // Move the pointer to the menu tab item so that it's not over the menu in preparation + // for key press tests. This prevents the mouse accidentially selecting the wrong item + // by hovering. + var tabs = _session.FindElementByAccessibilityId("MainTabs"); + var tab = tabs.FindElementByName("Menu"); + tab.MovePointerOver(); + } } }