Dynamic Selector Validation Problem

I’m trying to automate a process wherein the robot opens Notepad, and depending upon what value I put as default for the UiPath variable MenuOption (currently the value is “View”), the robot either opens up the File, Edit, or View menu options.

The Dynamic Selector won’t validate and I think my syntax is correct. I have no explanation of why it’s not validating.

When I actually run the bot, it always clicks on File regardless of what value I have in MenuOption (it always clicks on File because that’s the menu option I indicated for the Click activity, but the functionality I want is to click on any of the 3 menu options based on the value of the MenuOption variable).

I’m modifying the Strict Selector - not the fuzzy selector or window selector.

See attached screenshots.

The line of the selector in question is

<uia automationid='File' cls='Microsoft.UI.Xaml.Controls.MenuBarItem' name='{{MenuOption}}' />

The original partial selector was

<uia automationid='MenuBar' role='menu bar' /> 
<uia automationid='File' cls='Microsoft.UI.Xaml.Controls.MenuBarItem' name='File' />

Looked through the forums and couldn’t find an answer. Much appreciated. Thanks - Josh

2

@jamoros

To test the selector at design time, assign default value like view or edit to variable MenuOption and then click on validate.

Also to make it more dynamic, update title in the selector like this.

title='*Notepad*'

Hello ashokkarale! I have already assigned a default value to MenuOption. (See my screenshot). I made the default value “View”. The problem is when I click on Validate, it does not validate, and so the selector is not dynamic.

Thank you for the tip on making it more dynamic as well.

Edit: Not sure why the screenshot didn’t show up initially but I reuploaded it so you can see.

Okay after making this change

<uia automationid='MenuBar' role='menu bar' /><uia automationid='{{MenuOption}}' cls='Microsoft.UI.Xaml.Controls.MenuBarItem' name='{{MenuOption}}' />

it now validates and works. But now another problem has arisen. When I try to do a second activity (in this case, a hover activity) to move the mouse from View to Edit, the mouse still goes to File. I made sure the Hover activity has the same dynamic selector that has {{MenuOption}} in both places. Why is this happening?