Save a value and verify later

5 posts, 2 answers
  1. Adriane
    Adriane avatar
    28 posts
    Member since:
    Apr 2012

    Posted 04 May 2012 Link to this post

    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
  2. Answer
    Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 04 May 2012 Link to this post

    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
  3. Adriane
    Adriane avatar
    28 posts
    Member since:
    Apr 2012

    Posted 04 Jun 2012 Link to this post

    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)
  4. Answer
    Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 04 Jun 2012 Link to this post

    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
  5. Adriane
    Adriane avatar
    28 posts
    Member since:
    Apr 2012

    Posted 04 Jun 2012 Link to this post

    Thank you very much, that was exactly what I needed :)
Back to Top