This is a migrated thread and some comments may be shown as answers.

Using element value from previous screen

2 Answers 60 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Talal
Top achievements
Rank 1
Talal asked on 06 Mar 2012, 12:30 AM

 

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 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 06 Mar 2012, 06:53 PM
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
0
Talal
Top achievements
Rank 1
answered on 08 Mar 2012, 01:42 AM
Thanks Anthony it is working now, I really apprecaite your help and support


Talal
Tags
General Discussions
Asked by
Talal
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Talal
Top achievements
Rank 1
Share this question
or