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

Save a value and verify later

4 Answers 163 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Adriane
Top achievements
Rank 1
Adriane asked on 04 May 2012, 03:56 PM
Hi,

I want to do this steps:
Navigate on a silverlight webapplication site. Click Search Button.
I get one result.
On the resultview I can see a textblock. Now I want to save the data from this textblock in a variable.
Do some other background steps.
Go again on the webapplication, search, get one result.
Now I want to verify, that the text is not the same as before.

My question is, how can I save the value from the textblock in a variable and verify it later?

As I recorded the test, I can access the Textblock, but did not find a way to save the value from the text with the Telerik GUI elements.
So I think I need to access it via code and save it in this step, where I can see it, right?
But how can I access the textblock from the code to do so?

There is one button "Add to project elements" to put the element in the elementsTree. I tried this one, and then tried to access in the next code step via
string sjobid = Pages.VPMSMediaCenter.SilverlightApp0.sjobidTextblock.Text;


But as I play the test, I got the error message:

Exception thrown executing coded step: '[AF001_QA001_Umbenennung_CodedStep1] : Save SJobID in variable'.
InnerException:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException()
   at ArtOfTest.WebAii.Silverlight.SilverlightAppsList.get_Item(Int32 index)

I am new to Telerik Teststudio, maybe there is a explanation (didn't find it in forum/documentation) somewhere?
Or someone can help me here?

Best regards,
Adriane

4 Answers, 1 is accepted

Sort by
0
Accepted
Anthony
Telerik team
answered on 04 May 2012, 04:34 PM
Hello Adriane,

It sounds like you're after the Extraction feature.

Kind regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Adriane
Top achievements
Rank 1
answered on 04 Jun 2012, 09:42 AM
Hi, sorry for the delay.
It worked for me to get some values out of my silverlight DOM.
In the end I have two variables with two numbers in it.

What I want to achieve now it to compare those numbers, verify if they are different, if yes, it is correct.
How can I verify this with Extraction variables?

(what I can do is put the variables in a data driven binding and put it in another textfield for example, but that is not what I need)
0
Accepted
Anthony
Telerik team
answered on 04 Jun 2012, 01:40 PM
Hello Adriane,

The most direct way is to reference both Extracted Variables in Code and then assert that they are not equal (which will Fail the Test if they are equal).

Here's an example:

object myData1 = GetExtractedValue("var1");
object myData2 = GetExtractedValue("var2");
 
Assert.AreNotEqual(myData1.ToString(), myData2.ToString());

If you prefer Visual Basic, use our code converter.

Regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Adriane
Top achievements
Rank 1
answered on 04 Jun 2012, 03:45 PM
Thank you very much, that was exactly what I needed :)
Tags
General Discussions
Asked by
Adriane
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Adriane
Top achievements
Rank 1
Share this question
or