Resources

Knowledge Base

How to click an element specified by an user

In this scenario we are trying to click the menu items in Notepad depending on the input we provide.


There are multiple approaches to implement clicking elements based on particular input:

  1. Text Automation
  2. Variable Selector
  3. FlowSwitch Activity
1. Text Automation

Using the text automation technique you can directly specify the selected menu item in click text activity.

Text Automation - Click Text Activity

2. Variable Selector

If your menu item contains the name of the item in the selector, then a variable selector can be constructed and used in the Click activity.

In this case we’re using the string format function to construct a selector for the menu item the user specified. This selector will be used in the following click activity.

Variable Selector

* You don’t need to concatenate the string the way we did, it’s for visual purpose only. The original expression looks like this - String.Format("<wnd app='notepad.exe' cls='Notepad' title='Untitled - Notepad'/><ctrl automationid='MenuBar' idx='1' name='Application' role='menu bar'/><ctrl name='{0}' role='menu item'/>", MenuItemName)

3. FlowSwitch Activity

On this approach we define each possibility through the FlowSwitch activity and click on the item specified by the case. This is a good approach if you already know the values, they are not many and the number of the cases won’t change.

Here, as you can see, we have all the cases with the menu items that are contained in notepad.

Flow Switch activity with all the available options

You can find in attachments a sample (VariableMenuItem.zip) that exemplifies all these methods using menu items in Notepad application.

For a multi-select field, the approach is the same, the only difference will be to use the "CTRL" KeyModifier in the click activity in order to ensure that multiple selection is enabled.

VariableMenuItem