Question

I am working With Coded UI,when automating an application I need to select and item from winlist which have special characters like (parentheses, # etc), default SlectedItemsAsString() method is not working for this situation, I have found that giving the selection as string array worked with SelectedItems() method, Here is the example:

string templatename = item.Name;
String[] SelectedTempList = { templatename };
uILvwDetailsList.SelectedItems = SelectedTempList;

Does any one have better idea to select the winlist item with special characters using SelectedItemsAsString() method?

Was it helpful?

Solution

You can use the WinListItem.Selected() method. The string, typically, is the name property in Coded UI list items.

            WinWindow form1 = new WinWindow();
        form1.SearchProperties[WinWindow.PropertyNames.Name] = "Form1";
        WinList list = new WinList(form1);
        list.SearchProperties[WinList.PropertyNames.Name] = "listBox1";
        WinListItem listItem = new WinListItem(list);
        listItem.SearchProperties[WinListItem.PropertyNames.Name] = "2 -WinListItem with special characters !@%";
        listItem.SearchConfigurations.Add(SearchConfiguration.ExpandWhileSearching);

        listItem.Select();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top