I'd like to start with a discussion of the structure of this code:
Each part has a specific purpose:
<myApplication> - Represents a pointer to your WPF application
Message__<username>__1112013 - Represents a pointer to a specific window opened in your application
ForwardMessageRadbutton - Represents a specific UI element in the target window
The rest (.User.Click) are actions to be performed on the target element.
One thing to keep in mind is that both the pointer to the window and the pointer to the element in your examples are just variable names in code. They could actually be anything. What matters during test execution is the content of those variables. The content is a definition of the find logic that will be used to locate the correct target window/target element.
Back to the variable names for a moment, during recording Test Studio uses properties of the windows and elements to auto generate the variable names. The variable names can be anything and you're even allowed to change those variable names in our Elements Explorer to any value that is meaningful to you (sometimes Test Studio generates names that are virtually meaningless to us humans). When generating variable names that represent windows in your application Test Studio takes the current window title (aka caption), replaces any spaces and special characters with the "_" character and uses the resultant string as the variable name. At the same time it stores the actual window title in the find logic for that variable.
Since your variable name looks like "Message__<username>__1112013" that tells me your window title must be something like "Message John Doe 1112013". Is that about right (can you share a screen shot what it actually looks like)? Assuming this is true, it tells me your application is dynamically generating the window title at run time, it's not a static value that never changes. This will be a problem for Test Studio because it assumes the window title will be static. When the window title changes Test Studio will fail to find it because the default recording and playback will look for the window title that was present during recording.
To address the problem you're running into we need to modify how Test Studio finds your window with the dynamic title so that it works properly in all cases i.e. works today and tomorrow and next week and next month. Unfortunately now I have to share a little bit of bad news... Test Studio has wonderful very flexible find logic for finding elements... but it doesn't have a built-in mechanism for handling dynamic window titles. I have filed a feature request here asking that something be implemented.
To overcome this we'll have to write a little bit of code that will iterate through all the windows in order to locate the correct one. The following code sample will find the first window attached to my "Family.Show" WPF application where the caption starts with the string "Message":
IList<WpfWindow> appWindows = Applications.FamilyShowexe.OwnerApplication.Windows;
// We found the window we want. Now do something with it
// action code here
I admit this is not an optimal solution but it should be workable for you.
Please don't hesitate to contact us again if you run into further problems.
the Telerik team