Accessing Extracted Variables in Code Behind

7 posts, 0 answers
  1. David
    David avatar
    12 posts
    Member since:
    Sep 2010

    Posted 11 Jan 2011 Link to this post

    I am evaluating the 2010 Q3 trial version of the WebUI Developer against a Silverlight application to see if it will work for us (Visual Studio 2010 and Silverlight 4 on Windows 7 with IE8).  I have been evaluating for a few weeks and really like the product!  Even so, I have a couple of issues that I cannot seem to figure out.

    1)  In the code behind of my test, I need to be able to write to a text file the value of variables that are extracted in the other (non-coded) steps.  I am able to write out static values that are located as elements within the DOM, but so far have not been able to figure out how to make the variable names defined in the variable extract to be visible to the code behind so that they can be written out.

    2)  A RadGridView contains the variable values described above.  The number of rows that will be displayed in the grid is not known beforehand, but will always be more than are visible without scrolling.  What is the best way to programmatically extract all of the values in the grid (even the ones that are not visible without scrolling)?  If the only way to extract the values is to scroll a row at a time and extract the values individually, what is the best way to determine when I have reached the bottom of the grid?  In other words, is there some status available in a step or something I can look for in a code behind to let me know I have reached the last row?  It seems the row count property for the grid is the number of rows visible and not the total number of rows.

    Thanks.
    -David
  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 11 Jan 2011 Link to this post

    Hi David,

    Thank you for taking the time to evaluate WebUI Test Studio. I hope you it fills all your web test automation needs.

    1) We now have a KB article that describes how to do this.

    2) Currently we don't have a great solution to this problem of components that us a virtualized container (i.e. hold more data than can be displayed at one time). The hurdle is that Silverlight only puts into the Visual Tree the UI components necessary to render the UI on the page. Is this Visual Tree that we access to interact with Silverlight applications.

    As an example, let's say you have a grid that holds 1000 rows of data but can only display 20 at a time. Silverlight typically will only put 22 rows of UI elements in the Visual Tree (20 visible plus one above and one below). the only way to get all 1000 rows is to page/scroll through all the rows visually taking snapshots of the data along the way. Yes it can be a painful process, but there's no better solution at this time.

    One day we would like to provide direct access to the data driving virtualized containers such as grids. We haven't cracked that technical challenge yet, but we're trying to.

    Kind regards,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
  3. David
    David avatar
    12 posts
    Member since:
    Sep 2010

    Posted 11 Jan 2011 Link to this post

    Cody, thank you for your reply.  The information in the KB "Get/Set Extracted Variables in Code" was very helpful.

    Since the data will come from an indeterminate number of rows in the RadGridView, how does one go about defining variable names in the non-coded steps at runtime?  I ask this because I don't know of any way to include some type of file output within a test step loop, so it seems the file write would need to be implemented as the final step (an added code behind step) after the indeterminate number of variables have all been extracted.  Is there any way to do what I need?

    Thanks.

    -David
  4. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 12 Jan 2011 Link to this post

    Hi David,

    Unfortunately non-coded steps cannot create/define new variables at run time, not even in a loop. They can only be defined at design time. Only coded steps can inject a new variable with a new name.

    What I would do in your place is to do it all in code (keep in mind I am very comfortable working in code, but I realize not everyone is), i.e. use non coded steps to navigate to my website, login, step forward to the page that displays the data, then in a coded step extract all the data and write it to disk all at once.

    The problem with trying to use a standard loop step is that they must run for a fixed number of times. Since you don't know the number of rows that will be present from the start, the loop will not meet this requirement. In a coded step we can detect the number of rows that are present and much more easily extract all of the data from all of the rows.

    One catch I must warn you about though, does the order of the data matter when you save it? We have found that Silverlight doesn't always store the data in the same order that it is being displayed in. Sometimes it actually maps between a row of data and where it is placed on the screen. This can be a killer if you're trying to validate the sorting order of data.

    To help get you started I have attached a sample test I put together a while ago that performs actually scans and verifies the sorting order of multiple columns of a RadGrid. I will admit that at quick glance the code looks a bit scary. It was necessary to overcome the peculiar way Silverlight stores and displays rows of data. You should be able to reuse most of the code to achieve your goal.

    Greetings,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
  5. David
    David avatar
    12 posts
    Member since:
    Sep 2010

    Posted 13 Jan 2011 Link to this post

    Cody, thank you so much for the help!
  6. Keith Hill
    Keith Hill avatar
    2 posts
    Member since:
    Aug 2009

    Posted 17 Nov 2011 Link to this post

    The link to the "KB article" (http://www.telerik.com/automated-testing-tools/support/kb/code/how-can-i-get-set-extracted-variables-in-code.aspx) loads a page that is a server error.   
  7. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 17 Nov 2011 Link to this post

    Hello Keith Hill,

    We did some reorganization in our User's Guide. Here's the new link:

    http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/extracted-variables-in-code.aspx

    Greetings,
    Anthony
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!