Correlation with Telerik Studio

2 posts, 0 answers
  1. Mark
    Mark avatar
    27 posts
    Member since:
    Nov 2011

    Posted 13 Jan 2013 Link to this post

    Hi All,
    I used to work with a lot of different testing tools and almost all of them had some correlation functions.
    I'm almost sure we have that kind of function with Telerik but I don't know where.
    What do I mean with correlation?
    For example, a common case: you simply record and playback a test case and you encounter errors in your playback. Often, those errors are related to the session values which are sent by the server to the client to identify that particular session.
    Another example, I have a test case: I should send a message via my application, this message is dated from the date of the record. Then, I log on to my application with another user who have to open the message. Telerik capture the message with the name xxxx<date of record>xxx
    Here is what Telerik has recorded:
    Applications.<myApplication>.Message__<username>__1112013.ForwardMessageRadbutton.User.Click(xxxxxx, xxxx, xx)
    Today if i record it again, I will have
    Applications.<myApplication>.Message__<username>__1412013.ForwardMessageRadbutton.User.Click(xxxxxx, xxxx, xx)
    In this example, how can I catch this information and reuse it for a second playback?
    Thanks in advance for your help.
  2. Cody
    Cody avatar
    3360 posts

    Posted 17 Jan 2013 Link to this post

    Hello Mark,

    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;
    foreach (WpfWindow aWindow in appWindows)
        if (aWindow.Window.Caption.StartsWith("Message"))
            // 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
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top