Can a Script Step be used for If ... Else verify

4 posts, 0 answers
  1. Matthew
    Matthew avatar
    16 posts
    Member since:
    Jul 2011

    Posted 19 Oct 2011 Link to this post

    I have a data driven test that currently needs the data binding altered to filter different rows for different environments. Is there a way to use a scripted step to check the environment and then run subsequent steps or skip them?

    thanks
  2. John
    John avatar
    8 posts
    Member since:
    Jul 2012

    Posted 19 Oct 2011 Link to this post

    Yes,
    please note that you will have to loop through the cycles.  Each row is a cycle ad include the following code here:

    If  Data("Environment")  =  "Win7"  Then
    'Enter what you need ran here.

    End   If

    I hope this help, if you need more help,
    John
  3. Matthew
    Matthew avatar
    16 posts
    Member since:
    Jul 2011

    Posted 20 Oct 2011 Link to this post

    While I could hard code every step into an if else block in code, what I would like to do is simply up the iteration index and set the executioncontect.currentdatarow to the next datarow, or if I am at the end of usable datarows, to end the test without throwing a failure.

    in psuedocode...

    while ( Data["environment"] != CurrentEnvironment )
    {
        if ( Executioncontext.currentdatarow == LastDataRow )
        {
            end test without error
        }
        executioncontext.setcurrentdatarow(NextDataRow)
    }
  4. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 25 Oct 2011 Link to this post

    Hello Matthew,
         I understand what you're trying to do.

    Currently it's not doable but I've logged this as a Feature Request:
    http://www.telerik.com/support/pits.aspx#/public/test-studio/8286

        You'll need to implement a workaround in order to skip an iteration:
    You'll need to create two tests. Let's call them MainTest and Subtest.
    Put all the automation actions in Subtest. Make MainTest data-driven. Now we're going to add Subtests as a TestAsStep in MainTest. However, we're going to do it in a coded step. Here's what the code will look like:

    Copy Code
    this.ExecuteTest("Subtest");
    This implementation will now allow us to skip an iteration in MainTest if we so desire:
    Copy Code
    if (  ! ActiveBrowser.Url.Equals("http://someurl.com") ) {
          this.ExecuteTest();
    }
    In this way if the condition you're looking for isn't met we won't go into Subtest. In effect we'll be skipping the iteration even though it won't seem so from MainTest's point of view. I hope I've managed to explain this clearly, let me know if you require additional assistance with this.

    Let me know if you have additional questions on this.

    Best wishes,
    Stoich
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top