question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to automate use of the "More" menu of Horizontal NavigationView

See original GitHub issue

Describe the bug

When using a NavigationView in horizontal mode and with enough items included that the “More” menu option is displayed, it is not possible to use automation tools to interact with the contents of the menu displayed when clicking the “More” button.

Is automated interaction with the menu supported? If not supported, is there a reason? If it is supported, how has it been tested?

Context I’m using automated tests (powered by WinAppDriver) to walk the entire navigation structure of an app to test that everything is as expected and there are no obvious errors. As the apps in question now include enough options to necessitate the “More” option/menu, it’s no longer possible to test the apps fully.

I can query how many items are in the pop-up, but querying details (such as the text) or trying to click on an item fails. The pop-up seems to be being created in the same way as the menu items in a MenuBar and I can query and interact with menubar items without issue. I’m assuming there is a non-obvious difference in the way the pop-up is created or there’s something special about the way that NavigationViewItems are displayed in the pop-up.

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Add a NavigationView with PaneDisplayMode="Top"
  2. Add enough items that the “More” menu will be displayed.
  3. Use automation tools to open the menu and query the contents of the list. Example code below.
var moreBtn = appSession.FindElementByName("More");
moreBtn.Click();
var popupMenu = appSession.FindElementByName("Pop-up");

var moreMenuItemsCount = popupMenu.FindElementsByClassName("Microsoft.UI.Xaml.Controls.NavigationViewItem").Count;
moreBtn.Click(); // Close menu so get in a consistent state

for (int i = 0; i < moreMenuItemsCount; i++)
{
    moreBtn.Click();

    // Find the pop-up again as it's recreated after opening the menu each time
    popupMenu = appSession.FindElementByName("Pop-up");

    var moreMenuItems = popupMenu.FindElementsByClassName("Microsoft.UI.Xaml.Controls.NavigationViewItem");

    // BOTH/EITHER OF THE FOLLOWING FAIL!
    var entryText = moreMenuItems[i].Text;
    moreMenuItems[i].Click();

    ....  // other code omitted
}

Expected behavior

It should be possible to query the contents of the pop-up menu in the same way as any other content. (This could be any content on the main window or in other pop-ups line menu flyouts.)

Screenshots

This menu:

image

Version Info

NuGet package version:

[Microsoft.UI.Xaml 2.4.2]

Windows 10 version Saw the problem?
Insider Build (19621) Yes
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context

Related issue also raised on the WinAppDriver repository: https://github.com/microsoft/WinAppDriver/issues/1204

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
StephenLPeterscommented, Jun 23, 2020

I think that this is effecting Narrator navigation within this popup as well

0reactions
mrlaceycommented, Jul 29, 2023

accessibility issues shouldn’t be closed without good reason

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to query NavigationViewItem in the "More" menu
When using a WinUI NavigationView in a UWP app with the horizontal mode set to "Horizontal" and more items than can be displayed...
Read more >
c# - Navigation View Not automatically closing
1 Answer. About the first issue,if you want to it close/minimize the menu to the left upon selecting the item,you can add PaneDisplayMode=" ......
Read more >
NavigationView - Windows apps
NavigationView is an adaptive navigation control that works well for: Providing a consistent navigational experience throughout your app.
Read more >
SwiftUI Navigation Stack pops back on ObservableObject ...
If the model userLoader is updated in any way, the stack pops back automatically to the first view. This is not the desired...
Read more >
The Complete Guide to NavigationView in SwiftUI
In this article I want to demonstrate the full range of ways you can use NavigationView in your apps, including simple things like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found