diff --git a/samples/IntegrationTestApp/MainWindow.axaml b/samples/IntegrationTestApp/MainWindow.axaml index 55c96490d5..29a8a254e5 100644 --- a/samples/IntegrationTestApp/MainWindow.axaml +++ b/samples/IntegrationTestApp/MainWindow.axaml @@ -94,6 +94,19 @@ + + + + + + diff --git a/src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml b/src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml index c8e2873eb6..451d1c85a4 100644 --- a/src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/ContextMenu.xaml @@ -38,6 +38,7 @@ + diff --git a/src/Avalonia.Themes.Simple/Controls/ContextMenu.xaml b/src/Avalonia.Themes.Simple/Controls/ContextMenu.xaml index 215f4eec5a..5c8f799f94 100644 --- a/src/Avalonia.Themes.Simple/Controls/ContextMenu.xaml +++ b/src/Avalonia.Themes.Simple/Controls/ContextMenu.xaml @@ -6,6 +6,7 @@ + diff --git a/tests/Avalonia.IntegrationTests.Appium/ContextMenuTests.cs b/tests/Avalonia.IntegrationTests.Appium/ContextMenuTests.cs new file mode 100644 index 0000000000..2d4ef14f45 --- /dev/null +++ b/tests/Avalonia.IntegrationTests.Appium/ContextMenuTests.cs @@ -0,0 +1,36 @@ +using OpenQA.Selenium; +using OpenQA.Selenium.Appium; +using OpenQA.Selenium.Interactions; +using Xunit; + +namespace Avalonia.IntegrationTests.Appium +{ + [Collection("Default")] + public class ContextMenuTests + { + private readonly AppiumDriver _session; + + public ContextMenuTests(DefaultAppFixture fixture) + { + _session = fixture.Session; + + var tabs = _session.FindElementByAccessibilityId("MainTabs"); + var tab = tabs.FindElementByName("ContextMenu"); + tab.Click(); + } + + [PlatformFact(TestPlatforms.Windows)] + public void Select_First_Item_With_Down_Arrow_Key() + { + var control = _session.FindElementByAccessibilityId("ShowContextMenu"); + + new Actions(_session) + .ContextClick(control) + .SendKeys(Keys.ArrowDown) + .Perform(); + + var clickedMenuItem = _session.FindElementByAccessibilityId("ContextMenuItem1"); + Assert.True(clickedMenuItem.GetIsFocused()); + } + } +} diff --git a/tests/Avalonia.IntegrationTests.Appium/ElementExtensions.cs b/tests/Avalonia.IntegrationTests.Appium/ElementExtensions.cs index 99c30085d6..52261d40f1 100644 --- a/tests/Avalonia.IntegrationTests.Appium/ElementExtensions.cs +++ b/tests/Avalonia.IntegrationTests.Appium/ElementExtensions.cs @@ -58,8 +58,7 @@ namespace Avalonia.IntegrationTests.Appium { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - var active = element.WrappedDriver.SwitchTo().ActiveElement() as AppiumWebElement; - return element.Id == active?.Id; + return element.GetAttribute("HasKeyboardFocus") == "True"; } else {