Using element value from previous screen

3 posts, 0 answers
  1. Talal
    Talal avatar
    19 posts
    Member since:
    Jan 2012

    Posted 05 Mar 2012 Link to this post

     

    Hi Guys
    in Silverlight application, I would like to use element value from previous screen (Screen 1) in the current screen (Screen 2) see the attachments. The element value from the screen 1 is highlighted in Red. The element in screen 2 highlighted in Red too, the display value of this element in screen 2 depending on the value of screen 1, the value of the element in screen 1 is between 1 - 3 for each value there will be different display value in screen 2. I have tried to make the element in screen 1 as a variable and use it in screen 2, I have add script step and use If..else statement in the scripted statement, but the problem the value of the variable in screen 1 (data driven) not recognised in screen 2.

    If you have any idea or example for this situation please let me know 


    Best Regards
    Talal 

  2. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 06 Mar 2012 Link to this post

    Hello Talal,

    It sounds like you've already used the Extract feature on the Hierarchy Depth value on screen 1. Now double click that step and set the DataBindVairableName to HierarchyDepth.

    To reference that variable in a later coded step, you'll need to Get the Extracted Variable in Code. Now you can use it in your IF statements.

    Here's an example I crafted against http://random.org/. I set the Maximum value to 3 in the "True Random Number Generator" area on the right. Then I clicked the Generate button. Finally I extracted the value in the Result area and set the variable name to HierarchyDepth. Here's sample code from the coded step:

    object myData = GetExtractedValue("HierarchyDepth");
    string hd = myData.ToString();
     
    if (hd == "1")
    {
        ActiveBrowser.NavigateTo("http://ask.com");
    }
    if (hd == "2")
    {
        ActiveBrowser.NavigateTo("http://bing.com");
    }
    if (hd == "3")
    {
        ActiveBrowser.NavigateTo("http://cnn.com");
    }

    You can easily replace the NavigateTo lines with the verification you'd like to perform.

    Greetings,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Talal
    Talal avatar
    19 posts
    Member since:
    Jan 2012

    Posted 07 Mar 2012 Link to this post

    Thanks Anthony it is working now, I really apprecaite your help and support


    Talal
Back to Top